Moritz Lenz wrote:
On Wed, Nov 18, 2009 at 12:33:35AM -0800, Darren Duncan wrote:
For example, say I want the following expression to result in a FatRat because presumably that's the only type which will represent the result value exactly:

  45207196 * 10 ** -37

How should that be spelled out in terms of 3 integers?

why 3?

I think Jon Lang gave a good reply to that.

I will also add, because that's conceptually what an IEEE float does, and technically an IEEE float is still exact precision but it is limited in what values it can represent so selecting an IEEE float value in the first place may involve rounding, but once you have, the 3-integer representation of a rational allows the float to be represented as a rational, tersely, and also radix agnostically if the 2 or 10 is explicit. And it works with just-as-minimal memory use when you convert from a 64-bit float like "8.125*2**-4000".

FatRat.new(45207196, 10**37);

And note that a decimal-specific answer isn't what I want, since I want something that would also work for this:

  45207196 * 11 ** -37

FatRat.new(45207196, 11**37);

Solomon Foster wrote:
What's your objection to FatRat.new(45207196, 11 ** 37)?

Well, for one thing, that's not the same value. I had a "-37" as the exponent, designating a small non-integer rational value, whereas the FatRat example had flipped this around to "37", not the same value.

Now I'm sure the format you showed looks great, but my concern is, does simply saying this:

  11 ** -37

... result in a FatRat and if not then how do I write "11^-37" in Perl 6 such that the resulting object retains the full precision of the value?

-- Darren Duncan

Reply via email to