Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: maximum value of a scalar

by JavaFan (Canon)
on Oct 21, 2008 at 09:33 UTC ( [id://718427]=note: print w/replies, xml ) Need Help??


in reply to maximum value of a scalar

It will be different in Perl. First of all, Perl doesn't know integers - at least not on the Perl language level. Perl has numerical values.

Now, your question is ambiguous. I can put 1e100 in a scalar variable, and it will hold this. However, if I put 0 in a scalar, and repeatedly increment that by 1, I will never reach 1e100 because of loss of significancy.

But even if your question is "what is the largest integer a scalar can hold without losing significancy?", then the answer is "it depends". It depends on whether your perl uses 64 bit integers, or 32 bit integers. In the former case, the answer is 2**63-1, or 9223372036854775807. If you have 32 bit integers, the answer is not 2**31-1, but much higher. perl then uses a double to store the integer, but a double has enough bits to not lose precision for a while. I don't know where exactly the cutoff is, but I recall it's around 2**53.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://718427]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found