floor()

new topic     » goto parent     » topic index » view thread      » older message » newer message

for those among us, who haven't done any floor(-x [/y] ) yet,
make a note that floor(-1.5) yields -2. this is of course fully
correct because -2 is the next lower to -1. however, you might
expect the floor()ing done towards ZERO, which in calculations
would be easier. So be aware, when doing arithmetics on the
results to add 1 to the floor(-x/y) result.

floor(-1.5) * 2 + 2 * remainder(-1.5,1)   yields -5

i tripped over it while working on icd-math.

antoine tammer

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu