-------- Original-Nachricht --------
> Datum: Fri, 18 Apr 2008 15:29:22 +0100
> Von: "Paul Herring" <[EMAIL PROTECTED]>
> Nope. You're likely to hit NaN's and other weird and wonderful
> artifacts of IEEE754 when handling the return value.
>
> Just make buffer static within the function and it'll be safe to
> return its address. Just don't use it in a multithreaded program and
> save the contents of the return before calling the function again.
>
I see. Thank you. Looks like swapping those bytes isnt as straightfoward as i
thought:S Anways, looking at my first function, i just realised , i can't
actually see the problem. Even without declaring buffer as static, why should
there be a problem? I am returning the value of buffer, not its address. And
store that value it returns, on calling the function....Not sure what i forget
here?
float someFloat;
someFloat = floatSwap (someFloat);
float floatSwap(float f)
{
char* value = (char *)&f;
static char buffer[ 4 ];
buffer[0] = value[3];
buffer[1] = value[2];
buffer[2] = value[1];
buffer[3] = value[0];
return *((float*)&buffer);
};
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger