Skip to main content

Precision & Scale

Ephemeris needs to represent the entire solar system, at these extreme scales the precision of floating point numbers can become a serious issues. For example if the aphelion of Jupiter (5.4570 AU) is stored as metres (816,356,000,000) then the smallest possible step a single precision float (i.e. C# float, Rust f32) can represent is 65.5 kilometres!

This is a problem even on much smaller scales smaller scales. For example Unity, which uses single precision floats, recommends a max map size of 50km. At this scale the smallest possible step size is 1.95mm.


It is tempting to think that scaling the units in use, for example representing all positions as kilometres instead of metres, will gain back more precision. This is wrong.

Scaling the value down by some factor (e.g. 1000) does improves the smallest possible step size, but that step is now measured in larger units and thus has to be scaled up by the same factor. These two operations effectively cancel each other out. You can see this effect in the calculator below; the "scale" setting reduces the scale of the value but increases the scale of the step size.


Given a distance (the actual distance you want to store) and a scale (sets what the number '1.0' actually represents) calculate the smallest possible distance that can be represented at that distance.

  • Distance: 816.000000Gm
  • Stored Value: 816356000000
  • Single Precision: 65.300000km
  • Double Precision: 122.000000um

This calculation is done by reinterpreting (i.e. converting it without changing the bit pattern at all) the floating point value as an integer (see here), incrementing the integer and reinterpreting it back to a float. This gets the next value along the "number line" which is the smallest possible change in value that can be represented.

Relevance To Ephemeris

Example step size at various planets:

  • Jupiter (5.5AU/816_100_000_000m): 0.12mm
  • Saturn (10AU/1_503_980_000_000m): 0.24mm
  • Uranus (20AU/3_006_389_400_000m): 0.48mm
  • Neptune (30.3AU/4_537_300_000_000m): 7.18mm

Ephemeris is a realistic game based on plausible, near-future technology. It is extremely unlikely this level of tech will be able to reach the farthest reaches of the solar system in any kind of vehicle that can engage in combat! The game will not set any missions beyond Uranus, to avoid exceeding the 1mm minimum step size. This yields a smaller step size than the 1.95mm step size which Unity themselves recommend.