in reply to Re: rounding to nearest integer
in thread rounding to nearest integer
The floating-point parts of s?printf() are not implemented directly in perl itself, but handed off to the system library's sprintf() function. As a result, you are at the mercy of any bugs (in rounding or anything else) in the particular version of the system library you (or your customer) are using.
This is the only part of s?printf() handed off in that way in modern perls. In general, I tend to avoid use of floating-point numbers as far as possible in any application for which precise results are important - often you can model the values you need with integers or rationals, and the Math::Big* family of modules can also help out.
Hugo
|
|---|