Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

integer pragma buggy? (ANSWERED)

by LanX (Saint)
on Jun 02, 2025 at 22:14 UTC ( [id://11165215]=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

(in continuation to Re^7: Largest integer in 64-bit perl (RFC))

According to integer it'll adjust the ** operation to integer, even on 64bit machines.

This seems to break as soon as the precision of floats at 53bits is exceeded°

Am I missing something?

$ perl $\="\n"; print log(3**34)/log(2); use integer; print int(3**34); __END__ 53.8887250245193 16677181699666570

NB: a power to the basis 3 can't ever be even (odd*odd is odd) and the correct number is 16677181699666569 according to Math::BigInt ...

To answer my own question ...

... it's documented, doh.

> The power operator ** is also not affected,

I was confused by the fact that the synopsis explicitly shows the power operator.

> $a = 2**31 - 1;  # Largest positive integer on 32-bit machines

Honestly I thing integer is far too incomplete to be of big use.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

°) or more likely never have been properly implemented in the first place, because it was developped and tested on 32bit machines

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11165215]
Approved by dorko
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2025-06-17 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.