Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't know in details how exactly using floating point numbers to do so causes problem, but clearly it did cause problems for KSP.

I'm afraid that sums up the problem with your idea. You are positing a solution to a problem that you do not fully understand.

Almost all problems with floating point math are down to programming errors that accumulate, because intermediate values are wrongly rounded or truncated.

64-bit precision floating point math, with its 17 (16.94!) digits of decimal accuracy is more than capable of representing any given point within the Solar System in meters to the nearest millimetre. Problems only arise when absolute positional values are calculated by accumulating successive positions and their rounding errors.

That is to say: the naive way to track an objects position is to initialise it with a known starting point -- say the top of a rocket stack at some lat/long here on earth -- and then modify its position every time period (say, once per second) using the last known position as the input to the next time cycle.

The problem with this is that at each stage, tiny absolute representation errors can occur. Individually, these tiny errors in the 17 (decimal) significant digit are inconsequential; but each time the calculation is repeated, they can build up to the point of significance.

There are many techniques for avoiding those accumulated errors -- a whole branch of mathematics is dedicated to exactly that, which I do not know well enough to attempt a summary of here.

Even if the game required greater accuracy that could be achieved with 64-bit FP, moving to infinite precision irrational math as a response would be to take a sledgehammer to crack a nut. A simple move to 80-bit (21 significant digits) or 128-bit (34 sig. fig.) is a relatively simple change with minimal performance impact, that ensures that rounding errors would take trillions of repetitions - 1 trillion calculations at 1 per second represents a game time of ~11.6 million years! -- before they accumulate to anything significant.

But even that is overkill for a game. If the math is done correctly, 64-bit FP is more than good enough for real life problems like manned space flight and modeling nuclear weapons. It is certainly good enough for games where the speed of computation is far more critical than the accuracy.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


In reply to Re^7: Irrational numbers by BrowserUk
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":



  • 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 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?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found