How do you round down a number?

Blitz3D Forums/Blitz3D Beginners Area/How do you round down a number?

767pilot(Posted 2005) [#1]
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


Stevie G(Posted 2005) [#2]
This is what your after ....

http://www.blitzbasic.com/b3ddocs/command.php?name=Floor&ref=2d_a-z


Shagwana(Posted 2005) [#3]
int(num) can be used for such a thing


Stevie G(Posted 2005) [#4]
Not true as INT( 14.999 ) will be 15.0 and floor() would be a pointless function.


IPete2(Posted 2005) [#5]
How about

if a >14 and a <15 the a=14


????

lol

IPete2.


big10p(Posted 2005) [#6]
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




Shagwana(Posted 2005) [#7]
well i stand corrected if thats true then!