i've finally figured out how to round my numbers down. there's a nifty function in mysql called round(), and round() can round to a specified number of decimal places.
but - wait. the numbers aren't always right. there's a known bug in the round() function, so the mysql reference manual advises using truncate() and floor() instead. okay. i'll bite.
so i add 1/2, floor it, truncate it... and i still get an incorrect round result. the exact same result the round() function gave me. i've been scratching my head over this one enough already, so i start playing with the numbers.
i'm obviously doing something wrong here, right?
...
well, i've discovered the problem. here's my conversation with nystire:
totalwaste says:
so what i have to do is truncate(floor(x+.5))
although that's only in theory
to get it to return the CORRECT values
i need to use x + .55
why the extra .05, you may ask?
go on, ask
...
nystire says:
ok, i'll bite. why?
totalwaste says:
BECAUSE THE ENTIRE FUCKING MATH PACKAGE IS FLAWED, AND IT CAN'T BLOODY WELL *ADD* OR *SUBTRACT* CORRECTLY!
sodding *@$!!#$s.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.