-------- Original-Nachricht --------
> Datum: Thu, 17 Apr 2008 07:12:01 -0700
> Von: Thomas Hruska <[EMAIL PROTECTED]>
> Instead of swapping bytes, you could always use shifting.  Bits in bytes 
> are almost always ordered the same way (bit 7 to 0).
> 
> char MyInt[sizeof(int)];
> 
> for (int x = 0; x < sizeof(int); x++)
> {
>    MyInt[x] = (char)(YourInt & 0xFF);
>    YourInt = YourInt >> 8;
> }
> 
> -- 

Thanks! But , that method does not work with floats, right?
Heres what im currently using to swap floats (seems to be giving me the right 
numbers):

float floatSwap(float f)
{
char* value = (char *)&f;
char buffer[4];
buffer[0] = value[3];
buffer[1] = value[2];
buffer[2] = value[1];
buffer[3] = value[0];
return *( (float *) &buffer );
};

-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free

Reply via email to