go ahead... be a heretic PerlMonks

### Re^6: Irrational numbers

by grondilu (Friar)
 on Dec 18, 2012 at 14:05 UTC ( #1009370=note: print w/replies, xml ) Need Help??

in reply to Re^5: Irrational numbers

So you are going to calculate the positions of the simulated spacecraft within your game, to millimetric accuracy, despite that you would need a screen the size of the Earth's orbit around the Sun in order to notice the difference?

No. The point is to use the same numerical object to represent the position of the spacecraft, all the way from take off on ground level to orbit and docking. 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.

PS. Also, with a program like KSP, you may not have a screen as big as the solar system, but it's just as if. You have a huge range of numerical values that makes a virtual scene just that big.

Replies are listed 'Best First'.
Re^7: Irrational numbers
by BrowserUk (Pope) on Dec 18, 2012 at 15:16 UTC
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.

Create A New User
Node Status?
node history
Node Type: note [id://1009370]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2017-08-18 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (307 votes). Check out past polls.

Notices?