in reply to Decimal precision issue: Windows vs. Unix

As for the "why" of rounding errors associated with the representation of floating point base-ten numbers using a binary subsystem, see perlfaq4, and perlnumber. This is a pretty common question. On any given day there's about a 5% chance some version of this question will show up here, which earns it a slot in the FAQ.

To answer why two versions of Perl produce different versions of the rounding error, that's most likely a difference in the build, either as it pertains to the compiler's nuances, or the architecture targeted by the compiler.

At any rate, floating point numbers really don't make good lookup keys. If absolute precision is required, you're probably better off stringifying and manipulating the stringified representation of numbers by hand, or re-thinking the strategy altogether so as to favor a more reliable lookup method.


Dave

  • Comment on Re: Decimal precision issue: Windows vs. Unix