If I am dealing with integers that can get anywhere near the safe limit (which is a lot of the time), I use a bigint library.
Fair enough, but all the OP wanted was to test whether a positive integer value was greater than ~0.
If you think it's fair enough that checking whether
$non_negative_integer_value > ~0 should
not necessarily be sufficient, then that's fine by me - you've got what you want, and you're welcome to stick with your 64-bit precision IV & 53-bit precision NV perl configuration.
To me, the behaviour (re integer-float conversions) on this and only this IV/NV configuration is interesting and challenging, up to a point. But it's poorly thought out (if it was ever actually thought out at all), and having to deal with it is counter-productive. Perl is supposed to DWIM and to make things easier, and this particular configuration falls down in those 2 regards.
That, nearly a quarter of the way through the 21st century this configuration is still arguably the most prevalent by far, makes me wonder about the mental acuity of perl programmers - at least those perl programmers that are interested in perl's math operations.
OTOH, for all other possible IV/NV permutations perl's math behaviour (re integer-float conversions) is sane, helpful, DWIMs, and makes things easier.
Cheers,
Rob
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.