Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Rounding to the lower number (http://www.programmingforums.org/showthread.php?t=2701)

Navid Mar 10th, 2005 12:43 PM

Rounding to the lower number
 
Math.round(4.7)


How do I round to the lower number? (4 in this case)

Dizzutch Mar 10th, 2005 4:58 PM

integer division by 1..:) there might be a floor function, but i don't know JavaScript that well.

Navid Mar 11th, 2005 12:02 PM

you mean 4/1?

But that would still leave me with a decimal.

Dizzutch Mar 11th, 2005 1:35 PM

not if you do integer division, but i don't know if you can do that in JS. IN C at least
float a = 4.3;
int b = 1;
int c = a / b;
printf("%d\n", c); // prints 4

Ooble Mar 11th, 2005 4:36 PM

I believe num.floor() works as well.

Navid Mar 11th, 2005 5:19 PM

you probably ment Math.floor()

it worked, thanks

Ooble Mar 11th, 2005 5:21 PM

Shhh...


All times are GMT -5. The time now is 7:57 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC