Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
This is an issue with Perl, not with this module. Huge numbers get converted to floats automatically by Perl. You can't convert back, as you suggest, because you've lost accuracy:
$ perl -e 'print 10000000000000001, $/' 1e+16 $ perl -e 'print 10000000000000005, $/' 1e+16 $ perl -e 'print 10000000000000000, $/' 1e+16
You will find that every module on CPAN that needs to deal with integers this big either (A) requires you to pass the number as a string, or (B) uses Math::BigInt or similar, to prevent Perl from converting the integer to a float. Even notice from Math::BigInt's pod:
Scalars holding numbers may also be passed, but note that non-integer +numbers may already have lost precision due to the conversation to float. Quot +e your input if you want BigInt to see all the digits: $x = Math::BigInt->new(12345678890123456789); # bad $x = Math::BigInt->new('12345678901234567890'); # good

blokhead


In reply to Re: Number::Spell by blokhead
in thread Number::Spell by PERLscienceman

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2021-11-30 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?