Bad example. 1/8 == 1/2^3 => exact floating point number (0.125) - unless your hardware is broken...
0.1 or 0.7 are values I know are NOT representable in floating point.
--
Mats
Printable View
I know, I didn't think of that, but I think the point was that a division with 1 and 8 would in real life give 0.125. So if done "correctly" in C/C++, it should be 0.125 too (and not 0.12500001).
Thx everyone for help...
Just for record I solved it by putting into the calculator a slide-bar by which a user selects how many decimals does he want... Useful because it automatically rounds up decimals
I use _snprintf() as it is safer and less likely to crash your app than sprintf()