Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Infinity and Inf? (MAX_INT)

by BrowserUk (Pope)
on Sep 01, 2010 at 13:16 UTC ( #858333=note: print w/replies, xml ) Need Help??


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

The MAX_INT is somewhere between 2**49 and 2**50!

Your test is flawed. The maximum integer that can be accurately stored in a NV is 2**53 = 9007199254740992.

printf "%.15f\n", 2**53;; 9007199254740992.000000000000000

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^5: Infinity and Inf? (MAX_INT)
by LanX (Bishop) on Sep 01, 2010 at 13:27 UTC
    > Your test is flawed.

    see my updates in the meantime!

    Cheers Rolf

      Your test is still flawed because MAX_INT is not MAX_UINT nor is it "the maximum of the range of integers that can be exactly stored in an NV". ~0 is MAX_UINT. MAX_INT is int(~0/2), which is 32 bits on some builds of Perl but not on others. See "IV".

      for( my $i= $start; 1; $i++ )

      Update: And it is usually spelt INT_MAX, it seems.

      - tye        

        > Your test is still flawed.

        see my updates in the meantime!

        Nota Bene: There are no restrictions of the range operator documented in perlop.

        > See "IV".

        Actually I'm expecting to work in a high level language which abstracts the implementation details away.

        Sure I could analyze the C-sources but thats not why I use Perl.

        > grep -l " IV " /usr/share/perl/5.10/pod/*.pod /usr/share/perl/5.10/pod/perlapi.pod /usr/share/perl/5.10/pod/perlguts.pod /usr/share/perl/5.10/pod/perlhack.pod /usr/share/perl/5.10/pod/perliol.pod /usr/share/perl/5.10/pod/perlreapi.pod /usr/share/perl/5.10/pod/perlxs.pod

        Cheers Rolf

        UPDATE:

        For those interested perlnumber holds some infos... especially:

        In fact numbers stored in the native integer format may be stor +ed either in the signed native form, or in the unsigned native for +m. Thus the limits for Perl numbers stored as native integers would typ +ically be -2**31..2**32-1, with appropriate modifications in the case +of 64-bit integers. Again, this does not mean that Perl can do op +erations only over integers in this range: it is possible to store many +more integers in floating point format.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://858333]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2017-10-22 09:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (272 votes). Check out past polls.

    Notices?