I'm working on a game, and my intent is to avoid use of floating point for unit positions. To that end, I'm using 32-bit integers for all positions, with a millimeter scale.
However, for rendering, I know the GPU expects everything to be float, so I need to convert from millimeter-scale integer to meter-scale float. Sounds simple, but I'd like to know the most efficient way to perform these two conversions at the same time without losing something along the way.
I know I can convert my 32-bit integer to a double and know that it will all fit, before dividing by 1000 to get meters and converting the result to a float:
int i = 1234567890; double d = i / 1000.0; f = (float)d;
But I wonder if that's taking more steps than is necessary. The only other option I can think of is to do something like:
int i = 1234567890; float f = (i % 1000) / 1000.0f; f += i / 1000;
But that requires multiple divides and more steps than using a double.
Is there perhaps another existing method of performing this sort of conversion? Or are these my only real options?