in reply to Re^2: [s]printf %d oddity
in thread [s]printf %d oddity
update:
Think of it like this: decimal floats are inaccurate too, since they can't represent a rational number like 1/3 in finite notation:
1/3 = 0.333333333333333333....
If all arithmatic was done using decimal notation, assuming a maximum of 10 places you get:
$x = 1/3; # 0.3333333333 $y = $x * 3; $y == 1 -> false # $y == 0.9999999999
The same thing happens here, only since humans have a hard time thinking in floating binary, it's much harder to predict where.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: [s]printf %d oddity
by astroboy (Chaplain) on May 20, 2005 at 10:13 UTC | |
by Joost (Canon) on May 20, 2005 at 11:45 UTC | |
by Anonymous Monk on May 20, 2005 at 11:24 UTC |