in reply to Re^3: Infinity and Inf? (MAX_INT)
in thread Infinity and Inf?

You are mistaken. We were talking about the maximum value that can be used in a range, and it's not even close to 2**50.

(By the way, the largest positive integer that can be stored without loss of precision in a double-precision float is 2**53.)

I was wrong too, though. I thought it was the largest native unsigned integer, but it's the largest native signed integer.

$ perl -e'1 for 2147483647..2147483647' $ perl -e'1 for 2147483647..2147483648' Range iterator outside integer range at -e line 1.

That limit be obtained using the following:

use constant MAX_RANGE => (~0)>>1;

Replies are listed 'Best First'.
Re^5: Infinity and Inf? (MAX_INT)
by LanX (Saint) on Sep 01, 2010 at 16:36 UTC
    > You are mistaken.

    did you read my updates before answering?

    > That limit be obtained using the following:

    I question these design decisions forcing the user to care about such implementation details.

    From a higher language perspective it doesn't make sense why a range operator within a for(..){} can't iterate thru the same spectrum like a while($x++){ } can do.

    IMHO the cleanest syntax would be allowing to use Inf which is automatically translated to whatever maximum the current implementation of an operator can handle.

    Cheers Rolf

      I question these design decisions forcing the user to care about such implementation details.

      Which users are those? Very few will ever needed to iterate over numbers greater than 2,147,483,648, and very few will ever need to iterate over numbers greater than 9,223,372,036,854,775,807 (64-bit builds).

      It's a compromise between resources and utility. Only using integers internally is faster, requires less memory and requires less code than supporting both integers and floats.

      the cleanest syntax would be allowing to use Inf

      If we pretend that for to take a lazy list, you'll complain that it doesn't make sense for map not to, from a higher language perspective.

      Mind you, I think for ($x..Inf) has merit.

      for(..){} can't iterate thru the same spectrum like a while($x++){ } can do.

      If you think the range op has a seemingly arbitrary limit, you should see ++'s! For example, 1e16 to 1e16 is ok, but 1e16 to 1e16+1 isn't.

      $ perl -E'for (my $_ = 1e16; ; ++$_) { say }' 1e16 1e16 1e16 1e16 ...

      Update: Mixed $x and $_ in last snippet. Fixed.