This code has been declared by its author to be Public Domain code.
Download source codeComments |
I have different results here (Intel Centrino Duo).
I let the loop run 100 times longer so that small changes in the CPU load won't affect the result, and had the following results BlitzMax built-in Floor: 2428
BlitzMax coded Floor: 2401
Extern C Floor: 2318 (note: I didn't use your C function, but the original C floor function from <math.h>). The differences between the built-in and the new floor are (at least on this machine) very small.
The only difference is that your function doesn't work with negative numbers ;) BMax and B3D always round to the lowest nearest integer; -0.3 will be rounded to -1.0, for example. Your function always rounds towards zero; -0.3 will be rounded to 0.0, so it's basically just a slow Int().
|
|
If you're only going to use it for positive numbers, I'd just go with Int(). It does the same as floor for positive numbers and is about 4 times faster on my machine, so it's worth considering.
|
|
Yes, but with numbers bigger than that, I think you lose the precision with floats, where flooring won't matter.
|
Code Archives Forum