in reply to Re: converting big hex to dec
in thread converting big hex to dec


Unfortunately that will exceed the 15 digit precision of a 64bit double. In fact, your answer doesn't match the result from the 64bit machine shown above, or this:
> perl -Mbigint -le 'print 0x123456789ABCDEF' 81985529216486895

--
John.

Replies are listed 'Best First'.
Re^3: converting big hex to dec
by BrowserUk (Patriarch) on Sep 27, 2005 at 13:54 UTC

    That's why I chose to show that particular value, to point out the limitation and make the OP think about what he is doing.

    If the OP's task is simply to convert ascii-hex to ascii-decimal, why is he (clumsily) restricting the scope of BigInt?

    The only reason for limiting it's scope that came to mind, is if he is doing math within the script that he doesn't want slowed by BigInt being involved, but if that is the case, then he should also realise that the moment he moves the 64-bit integer outside of the scope of BigInt, he faces the possibility of loss of precision when the values are greater than 53-bits.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.

      That's why I chose to show that particular value, to point out the limitation and make the OP think about what he is doing.

      I knew that. I just chose to show a counter example to point out the limitations of answering a question with incorrect code and no commentary.

      --
      John.