To clarify:

In the first place, the conversions given are incorrect. According to the Calculator app that comes with Windows Vista, A100 0000 (hexadecimal) is 2,701,131,776 (decimal). Conversely, 270,113,177,609,606,898 (decimal), which the OP was expecting, is actually 3BF A281 0092 96F2 (hexadecimal).

Next, sprintf("%u", 0x3BFA281009296F2) gives the correct answer on a 64int perl build, but on a 32int build it results in:

Integer overflow in hexadecimal number at ...

Yet even on a 64int build, which handles the command without overflow, use warnings produces:

Hexadecimal number > 0xffffffff non-portable at ...

All of which is a good indication that the OP’s idea to use Math::BigInt was the correct one.

But Math::BigInt is a class, so its ‘numbers’ are actually objects, which should be operated-on by methods. So:

#! perl use strict; use warnings; use Math::BigInt; my $n = Math::BigInt->new('0x3BFA281009296F2'); print $n->as_hex(), ' = ', $n->bstr(), "\n";

Output:

0x3bfa281009296f2 = 270113177609606898

which is portable and robust.

Athanasius <°(((><contra mundum


In reply to Re: Extra Long HEX to Decimal Converion Issue on Select Platforms by Athanasius
in thread Extra Long HEX to Decimal Converion Issue on Select Platforms by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.