C
cherbst
I'm getting a weird result with some rounding in a sprintf with perl
5.8.8:
c = 2.47 / 100; # => 0.0247
sprintf("%.1f", 18500 * c); # => 457.0 (NOT on FreeBSD)
sprintf("%.1f", 18500 * 0.0247); # => 456.9
FreeBSD gives 456.9 for both sprintfs, I was able to reproduce it on a
fresh FreeBSD 6.3 install with the perl binary package, and from a
compiled binary.
On Linux perl 5.8.8 gives 457.0, and I get that answer on everything
else I tried (ruby and python on Linux and FreeBSD). I tried using
each of the methods Math::Round, but that is different from sprintf on
Linux, and that is the behavior I was trying to get. Is anybody aware
of something like an unusual CFLAG that might be getting passed when
perl is compiled on FreeBSD?
5.8.8:
c = 2.47 / 100; # => 0.0247
sprintf("%.1f", 18500 * c); # => 457.0 (NOT on FreeBSD)
sprintf("%.1f", 18500 * 0.0247); # => 456.9
FreeBSD gives 456.9 for both sprintfs, I was able to reproduce it on a
fresh FreeBSD 6.3 install with the perl binary package, and from a
compiled binary.
On Linux perl 5.8.8 gives 457.0, and I get that answer on everything
else I tried (ruby and python on Linux and FreeBSD). I tried using
each of the methods Math::Round, but that is different from sprintf on
Linux, and that is the behavior I was trying to get. Is anybody aware
of something like an unusual CFLAG that might be getting passed when
perl is compiled on FreeBSD?