if numbers do go over 2 GB, Perl automatically upgrades you to floatsIf perl has been built with use64bitint and without uselongdouble, the "upgrade" can happen before the 2GB limit is reached ... which is definitely not what you want (as it means you've lost precision):
$ perl -MDevel::Peek -le 'Dump(17 + (2 ** 56))'
SV = NV(0x10450940) at 0x10410fd0
REFCNT = 1
FLAGS = (PADBUSY,PADTMP,NOK,READONLY,pNOK)
NV = 7.2057594037928e+16
In this instance, the workaround is to 'use integer':
$ perl -Minteger -MDevel::Peek -le 'Dump(17 + (2 ** 56))'
SV = IV(0x10429358) at 0x10410fdc
REFCNT = 1
FLAGS = (PADBUSY,PADTMP,IOK,READONLY,pIOK)
IV = 72057594037927953
Just a little trap for the unwary.
Cheers,
Rob
Update: Ooops - where *I* wrote 2GB above, I should have written "64-bit". And my point is unrelated to
tilly's, anyway ....
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.