Eski bir web tarayıcısı kullanıyorsunuz. Bu veya diğer siteleri görüntülemekte sorunlar yaşayabilirsiniz.. Tarayıcınızı güncellemeli veya alternatif bir tarayıcı kullanmalısınız.
64-bit integer instead of float in multiplayer games is a good idea?
A float (32-bit) has a 23-bit mantissa, so at roughly 2^23 (about 8 million) it starts to not be able to represent each integer anymore. So if you assume that you want to place things in a game world at least at 1 millimeter precision, your largest game world that you can represent somewhat safely in floats is 8 kilometers along 1 dimension. That’s not bad actually, but a bit limiting.. and for precise physics 1mm may not be enough.
A double has 52 bit mantissa (2^52 == 4503599627370496), so that is about 4 billion kilometers at 1mm precision, and generally much higher precision for smaller worlds than that.
Still, doubles are inherently non-linear in their precision, so using 64-bit integers representing millimeter or an even smaller unit may be desirable for storing world data.
Of course, as Jeff hints at, you can also store things as 2 numbers, e.g. a 32-bit int for a world cell, and then a float to represent an offset inside that cell.
Then, when you’re ready to do some heavy calculations for physics or graphics, first translate all coordinates involved to be relative to the current cell, entity, or player, after which you can safely convert to float since all coordinates typically will be small.