![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Rounding to the lower number
Math.round(4.7)
How do I round to the lower number? (4 in this case) |
|
|
|
|
|
#2 |
|
Professional Programmer
|
integer division by 1..
there might be a floor function, but i don't know JavaScript that well. |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
you mean 4/1?
But that would still leave me with a decimal. |
|
|
|
|
|
#4 |
|
Professional Programmer
|
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 |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I believe num.floor() works as well.
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
|
you probably ment Math.floor()
it worked, thanks |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|