The answer to this sort of question is not that straightforward. If you use a 32-bit perl, your values start out as an IV (integer value), so you might think the maximum is 2**31-1. If you however add one to that, the value will become an UV (unsigned integer value), and you might think the maxiumum is 2**32-1. However, when you add 1 to that, the value becomes a NV (float value). That one has a very high
maximum value, but that one is in fact irrelevant because long before that point you lose resolution and adding 1 will not change the value anymore. That typically happens somewhere around 9e15 (depends on the exact float resolution on your system). Still, this should be way beyond any foreseeable number of transactions unless you do millions of them per second (though if you need a string representation you may have to use (s)printf in order to get all significant digits).
Conclusion: normally you simply don't have to worry about integer overflow of a counter at the perl end.
If you need even more digits (or don't want to bother with (s)printf for big values), simply use an integer in string form and use ++, which will then be magic and have
no restriction whatsoever, e.g.:
perl -wle '$a = "9" x 100; $a++; print $a'
will give you 1 folowed by 100 zeros
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.