in reply to Floating point issue

Thank you, guys.

I'll use sprintf as a workaround...

Replies are listed 'Best First'.
Re^2: Floating point issue
by Laurent_R (Canon) on Aug 14, 2016 at 08:14 UTC
    A more accurate alternative might be to use integer arithmetic:
    $ perl -E '$c = -71123456; for my $i (0..19) {say $c/1000000; $c += 10 +000}' -71.123456 -71.113456 -71.103456 -71.093456 -71.083456 -71.073456 -71.063456 -71.053456 -71.043456 -71.033456 -71.023456 -71.013456 -71.003456 -70.993456 -70.983456 -70.973456 -70.963456 -70.953456 -70.943456 -70.933456
    You might also consider using the arbitrary big rational number module (Math::BigRat) or possibly the big float module (Math::BigFloat).

    Math::BigRat is accurate because it basically does integer arithmetic under the hood.