Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

It might indeed have a big cost in performance, though it's not so obvious. When adding two real numbers, there would be no computation whatsoever until an actual approximation of the result is requested. It could require lots of memory though, since there is a creation of a new closure (with all its context) for each arithmetic operation.

Another is: how would you ever decide when to stop calling for more digits...

This really is not an issue. It's like entering a drugstore and complaining about how there is too much choice. Accuracy would only affect numerical comparison and approximations. You can use a fixed value if you want. It depends on what you want to do with your numbers. The important thing is that it won't affect the way the calculations are done. Or in other words, it won't affect the result, only the way you show it.

Say you have a spaceship in a circular orbit around the sun with about an hundred thousands of millions of meters radius. That's about 150e9 meters. And you want to compute the position to a precision of the millimiter, because you worry about space debris for instance, or because you need to do some very advanced docking, or whatever). That would involve using angles as small as 6e-15 radians. So you'll need about 15 decimals of pi for you calculations. You wouldn't have to worry about that with an exact definition of pi. You would just make the calculations, and request a result with a millimeter precision. At no point you would have to worry about changing the definition of pi.


In reply to Re^2: Irrational numbers by grondilu
in thread Irrational numbers by grondilu

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (11)
    As of 2014-12-18 09:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (48 votes), past polls