in reply to floating points and sprintf
My guess: printf will round off to get what you expected, while sprintf %d does an int() which simply truncates. If the value were actually 14719.999999999999997, then that would explain the difference.
Note that floating point binary can't hold 1/10 exactly any more than decimal can hold 1/3 exactly.
Try using %.15f on such a value and see closer too what's really stored.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: floating points and sprintf
by kennethwlangley (Novice) on Nov 14, 2002 at 15:46 UTC | |
by John M. Dlugosz (Monsignor) on Nov 14, 2002 at 19:11 UTC |