Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: maximum value of a scalar

by ikegami (Pope)
on Oct 21, 2008 at 21:58 UTC ( #718599=note: print w/replies, xml ) Need Help??


in reply to maximum value of a scalar

For 32-bit version of Perl, the maximum integer (without using bigint or similar) that can be stored precisely is -253 on the negative side and 253 on the positive side.

>perl -e"printf qq{%.f\n}, 2**53+$_ for +1,0,-1" 9007199254740992 9007199254740992 9007199254740991 >perl -e"printf qq{%.f\n}, -2**53+$_ for +1,0,-1" -9007199254740991 -9007199254740992 -9007199254740992
build settingsMax positive integerMax negative integer
32-bit ints and double floats253 = 9_007_199_254_740_992-253 = -9_007_199_254_740_992
64-bit ints and double floats264-1 = 18_446_744_073_709_551_615-263 = 9_223_372_036_854_775_808
64-bit ints and quadruple floats2113 = 10_384_593_717_069_655_257_060_992_658_440_192-2113 = -10_384_593_717_069_655_257_060_992_658_440_192

Some operators (notably the bit operators) won't work with every number in that range.
Some C extensions won't work with every number in that range.

Replies are listed 'Best First'.
Re^2: maximum value of a scalar
by Anonymous Monk on Mar 01, 2009 at 06:11 UTC
    I'm trying to compile for quadruple floats, and it's not obvious to me what the parameter is during configure. Suggestions? Thanks, Scott
      I'm trying to compile for quadruple floats

      What is your compiler's C data type for these "quadruple floats" ? I had assumed that, if a C compiler could handle "quadruple floats", it would be handling them as "long doubles" - in which case building with -Duselongdouble might do the trick.

      Cheers,
      Rob
        I'm using gcc on linux. Not sure what the compiler's data type for "quadruple floats" is, though "long doubles" are 16 bytes accordint to ./Configure. It seems that (2^128) should be enough. I have long doubles turned on, and general 64 bit turned on, but I still max out at 2^64 instead of 2^113. Is there an additional gcc flag I can pass in that anyone knows of to get the 2^113 limit? Thanks! Scott
      Sorry, none. I have no knowledge on the topic.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://718599]
help
Chatterbox?
[marto]: "no it's not that"...."weirdos "...
[marto]: List EXE_FILES installed by CPAN so a couple of people suggest that your code looks obfuscated. I'd have to ageree, from the perspective of those who can't follow all of that one liner, it doesn't read well
Veltro is a weirdo, obsessed with whitespace
[marto]: to use the word "obsession" when so few people have said so little about it is grasping at staws
marto wishes tye was around, he's so much better at this sort of thing
usemodperl likes tye!
usemodperl tye  too
[choroba]: Re^3: LiBXML: New markup while preserving earlier tags? would benefit from a couple of test cases
usemodperl meant tye 
usemodperl pokes Veltro with line noise

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2018-06-24 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?