Patrick R. Michaud via RT wrote:
>I don't know that we should expect .perl or any other operation on Num
>values to be preserving more precision than that.

I'd expect .perl to preserve whatever precision is there.  Accurately
representing the value, in a form understandable by .EVAL, is its
raison d'etre.

The value I'm using in this example is 2**70, a very round number
that is easily represented in floating point.  If the lengthy decimal
representation is putting you off, consider

> (2e0**70).perl.EVAL == 2e0**70
False

>    > (1180591620717411303424.0e0 + 1.0 ).Int
>    1180591620717411303424
>    > (1180591620717411303424.0e0 + 10 ).Int
>    1180591620717411303424

These are as expected: floating point rounding applies, and the results
obtained are the closest representable values to the mathematically
correct result.  This is a red herring.  My example doesn't invoke
any operation requiring rounding.  The initial decimal literal has the
exact representable value, which gets represented correctly as a Num.
I don't then perform any arithmetic on it.

-zefram

Reply via email to