Minecraft malfunctions with a low enough Y-value

minecraft-java-edition

I'm playing in the void with Minecraft when I suddenly realised that my Y gradually stopped working (exact value:Y=-36 028 797 018 963 968, can't really find the exact value). See this video:

First the decimal places start to stop updating. Then the whole Y co-ordinates update starts to slow. Then finally it freezes there and sometimes I get a lag spike. Why is this happening? What is the explanation behind this? Is the data too big to handle? Is my computer too slow to handle?

Best Answer

Because computers store numbers in limited precision.

With bigger numbers the precision gets worse and worse, because the numbers are stored something like 1.2345ยท10123 (but in binary... it's a long story).

Here, I try to decrease a big floating point number by different amounts. Notice how changing it by smaller amounts doesn't do anything.

>>> a = -360287969785042688.0
>>> a = a-1; format(a, 'f')       
'-360287969785042688.000000'
>>> a = a-5; format(a, 'f')       
'-360287969785042688.000000'
>>> a = a-10; format(a, 'f')  
'-360287969785042688.000000'
>>> a = a-15; format(a, 'f') 
'-360287969785042688.000000'
>>> a = a-20; format(a, 'f')  
'-360287969785042688.000000'
>>> a = a-25; format(a, 'f') 
'-360287969785042688.000000'
>>> a = a-30; format(a, 'f')  
'-360287969785042688.000000'
>>> a = a-35; format(a, 'f') 
'-360287969785042752.000000'
>>> a = a-35; format(a, 'f')
'-360287969785042816.000000'
>>> a = a-35; format(a, 'f')
'-360287969785042880.000000'
>>> a = a-35; format(a, 'f')
'-360287969785042944.000000'

Notice how the difference between numbers isn't actually 35. It is the smallest possible difference between two such huge numbers in binary floating-point representation.

The same happens in the game. Multiple times per second it tries to decrease your Y position by vertical speed, which is apparently less than this minimal difference between two neighboring numbers.

But if you teleport by a larger amount, you obviously can break that limit.

This is clearly outside the scope of this site. But there is plenty of information on floating-point numbers.