in reply to Re: Floating point issue
in thread Floating point issue
You might also consider using the arbitrary big rational number module (Math::BigRat) or possibly the big float module (Math::BigFloat).$ 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
Math::BigRat is accurate because it basically does integer arithmetic under the hood.
|
|---|