a small note RE: [SDL] Floating data types...
mongoose at WPI.EDU
Wed Jan 24 11:36:49 PST 2001
On Wed, 24 Jan 2001, Oisin Mulvihill wrote:
> You could side step the floating point issue by
> using integer to represent floating point values,
> this then eliminates floating point maths and can
> speed things up a bit. i.e take you maximum value
> and divide it by 2^32 (for a standard int) and this
> mean 1 represents some really really small unit for
> movement or whatever.
The three ways I've thought of so far are
1. Converting the binary representation, which doesn't look very feasible.
2. Breaking the number into two ints, before and after the decimal point.
3. Converting the number to a string of chars and back.
#3 seems to be the best option in that it will retain 100% accuracy. The
problem is that the conversions are slow and the size of the string that
is going to be sent will be quite large. Letting the user specify the
level of accuracy they wish would probably be a good option.
I was thinking of adding this to SDLnet along with some other stuff..
More information about the SDL