How do you round down a number?
Blitz3D Forums/Blitz3D Beginners Area/How do you round down a number?
| ||
If I have a number 14.632 for example, how do I round it down to the nearest whole number, in this case 14 ? I want the answer for anything above ie 14.001 - 14.999 so it will always be 14, same for 225 etc. thanks Graham |
| ||
This is what your after .... http://www.blitzbasic.com/b3ddocs/command.php?name=Floor&ref=2d_a-z |
| ||
int(num) can be used for such a thing |
| ||
Not true as INT( 14.999 ) will be 15.0 and floor() would be a pointless function. |
| ||
How about if a >14 and a <15 the a=14 ???? lol IPete2. |
| ||
Yes, floor() is what you want. Also, Int behaves in a bit of a weird way in blitz, so be careful! From the docs: Int converts floating point numbers by rounding to the nearest integer. NOTE: This is not the traditional meaning of Int in Basic. What about numbers exactly halfway between integers? The rounding is to the nearest even integer: Int( 2.5 ) ... produces 2 Int( 3.5 ) ... produces 4 |
| ||
well i stand corrected if thats true then! |