Hey, can you set the precision at which Math.round works? thanks.
If it follows the Javascript function no Math.round just rounds to an integer what were you tryin to do?
I was just making this preloader, it displays KB loaded out of total KB, and i wanted it to be to like 2 decimal points. I dont really need to know, i was just curious if its possible.
You can do
var res = Math.round(yourNumber*100)/100 ;
But if you want a fixed number of decimal places, it’s a bit more complicated.
I have a script to do just that if you give me 40 mins i’ll nip into my other office and get it for you.
Long story I’m in London at the moment and am at our sister comany office and can’t get to the system I need
see you in 40 mins!
var num
integer = Math.floor(num); <!–Split the integer part–>
decimal = num - integer; <!–Split the decimal part–>
DectoInt = decimal*100; <!–Convert Deciaml to integer–>
Roundme = Math.round (DectoInt); <!–Round the integer–>
InttoDec = Roundme/100; <!–Return the interger to rounded 2 place decimal–>
num = integer+InttoDec; <!–Rejoin the two parts–>
return num;
what is that? HTML comments?? :trout:
probably, been doing some hand coding this afternoon for a company I used to work for as I was down in London thought I’d look them up. Some things never change!