in reply to Re^2: Highest scalar = ???
in thread Highest scalar = ???

I suppose that depends on your definition of "integer". I was never much of a math student, so I use the comp. sci definition. So does Perl, sometimes:

$x = 2**(52+1); for (1 .. $x) { # not gonna get here! }

Produces:

   Range iterator outside integer range at foo.pl line 2.

Guess that's not an integer after all!

-sam

Replies are listed 'Best First'.
Re^4: Highest scalar = ???
by ikegami (Patriarch) on Oct 01, 2007 at 20:27 UTC

    I was using your own definition. You said ~0 was the highest integer that can be represented precisely without using Math::BigInt. That's wrong, and I explained why.

    Your original post if still wrong by your new definition. If you want to the highest integer that can be used in a range, both your answer of ~0 and your suggestion to use Math::BigInt for larger integers than ~0 are wrong!!

    I have already mentioned in this thread that ranges require signed integers, so ~0 >> 1 (2147483647) would be the answer.

    Update: I originalyl had ~-(~0+1) instead of ~0 >> 1, but that won't work if the system's floats have a smaller range than the integers.