Are floating(double and long double too) data types the same on all
platforms? That is do they all have the same mantissa, exponent,
endianess… I noticed SDL_net doesn’t have any conversion methods for
sending floats to machines of different endianess.
Also SDLnet uses right shifting to convert numbers from the machines
endianess to nbo. Why not use a macro based on the machines endianess,
then if it’s big endian time wouldn’t be wasted shifting the number to a
format it’s already in.
Are floating(double and long double too) data types the same on all
platforms? That is do they all have the same mantissa, exponent,
endianess… I noticed SDL_net doesn’t have any conversion methods for
sending floats to machines of different endianess.
Also SDLnet uses right shifting to convert numbers from the machines
endianess to nbo. Why not use a macro based on the machines endianess,
then if it’s big endian time wouldn’t be wasted shifting the number to a
format it’s already in.
Then just send doubles as Sint32’s. You’ll lose precision, but you can
probably live with it.
You can also use SDL’s byteswapping macros instead of htonl and ntohl.
-John–
Underfull \account (badness 10000) has occurred while \spend is active
John R. Hall - Student, Georgia Tech - Contractor, Loki Software
Are floating(double and long double too) data types the same on all
platforms? That is do they all have the same mantissa, exponent,
endianess… I noticed SDL_net doesn’t have any conversion methods for
sending floats to machines of different endianess.
2 issues: byte order and fp format. Most contemporary machines use
IEEE floats so you can safely spec that in a protocol. Use either 32
or 64 bit floats; oddball ones like 80 (intel) or 128 (sun) are out,
so are ancient stuff like ibm 360/VAX/Cray fp formats. You can
probably use the ordinary byte order macros to convert endianness —
this is not guaranteed but true in reality
Are floating(double and long double too) data types the same on
all
platforms? That is do they all have the same mantissa, exponent,
endianess… I noticed SDL_net doesn’t have any conversion methods
for> >sending floats to machines of different endianess.
2 issues: byte order and fp format. Most contemporary machines use
IEEE floats so you can safely spec that in a protocol. Use either 32
or 64 bit floats; oddball ones like 80 (intel) or 128 (sun) are out,
so are ancient stuff like ibm 360/VAX/Cray fp formats. You can
probably use the ordinary byte order macros to convert endianness
this is not guaranteed but true in reality
I know that Age of Kings are having a lot of problems due to float
point values, as not all the system ( and speaking on x86 system only
:-> ) compute the number in the same way.
To compute the value and having the same result on both system you are
going to need:
a) Same precision
b) Non buggy FPU
c) Good luck
But for common things there shouldn’t be many problems.