问题描述:

I finally got my infinitely zooming grid to work and tried out how much I can zoom. Everything worked fine until around 15,000,000,000,000x magnification where it got jerky and didn't move right anymore so I figured I had hit the limit of precision of whatever variable type its using. Then I tried zooming out and expected a similar limit but 5 minutes later, at magnification of 0.00000-insert 100 zeros here-0014829095701452545 it was still doing great. If 1 was 1m then that in relation would be Planck length inside a Planck length inside a Planck length. Crazy!

So not really a problem question but a curiosity one - What kind of types does javascript use for floats? and why is it capable of using much longer tiny numbers than big numbers?

网友答案:

The problem is where the precision loss is.

When you have a huge number, you start losing precision around the units, which can cause huge problems.

With a really tiny number, your precision loss is at very low decimal places, where you'd have precision loss due to not having enough digits to store the number anyway. So there's no real problem here.

Does that make sense? Basically it's the difference between:

1234567890123457000 -- big precision loss (321)
0.00000001234567890123457 -- tiny precision loss (0.000000...0001)
相关阅读:
Top