Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^7: Irrational numbers

by BrowserUk (Pope)
on Dec 18, 2012 at 15:16 UTC ( #1009398=note: print w/ replies, xml ) Need Help??


in reply to Re^6: Irrational numbers
in thread Irrational numbers

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


Comment on Re^7: Irrational numbers

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009398]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2014-10-31 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (223 votes), past polls