Round up OR down
Round up OR down
- Started
- Last post
- 7 Responses
- Dancer
In Javascript are half numbers/values (ie. 24.5) rounded up or down?
- rasko40
up I think, but I'm only half sure, best round my answer to the nearest correct value and take that as gospel.
- Dancer0
thank you for such a clear response. Up it is.
- welded0
Half a value is always rounded up.
- Engage0
Just like normal maths at school
- monNom0
you can use the Math object to go either way.
Math.floor will round down, even if it's .9
Math.ceil will round up.
rounding should go to the next integer when it hits .5
- ********0
Is that not actionscript though? Or do they use the same?
- monNom0
Javascript has a Math object too.