([BinaryCStream -encodeValueOfCType:at:withName:name]): Use memcpy()

instead of assignment to get the floats and doubles from the `at:'
argument.
([BinaryCStream -decodeValueOfCType:at:withName:]): Likewise, for
setting the values.  (Reported by M. Decugis
<mds@sepgifbr.sep.de.edf.fr>.)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1902 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-10-31 18:46:02 +00:00
parent fb7db67bd1
commit ea23788183

View file

@ -225,7 +225,8 @@ static int debug_binary_coder = 0;
volatile double value;
int exponent, mantissa;
short exponent_encoded;
value = *(float*)d;
memcpy (&value, d, sizeof (float));
/* Get the exponent */
value = frexp (value, &exponent);
exponent_encoded = exponent;
@ -245,7 +246,8 @@ static int debug_binary_coder = 0;
volatile double value;
int exponent, mantissa1, mantissa2;
short exponent_encoded;
value = *(double*)d;
memcpy (&value, d, sizeof (double));
/* Get the exponent */
value = frexp (value, &exponent);
exponent_encoded = exponent;
@ -383,7 +385,7 @@ static int debug_binary_coder = 0;
{
short exponent;
int mantissa;
double value;
volatile double value;
/* Decode the exponent and mantissa. */
READ_SIGNED_TYPE (&exponent, short, ntohs);
READ_SIGNED_TYPE (&mantissa, int, ntohl);
@ -391,7 +393,7 @@ static int debug_binary_coder = 0;
value = mantissa / FLOAT_FACTOR;
value = ldexp (value, exponent);
/* Put the double into the requested memory location as a float */
*(float*)d = value;
memcpy (d, &value, sizeof (float));
break;
}
@ -408,7 +410,7 @@ static int debug_binary_coder = 0;
value = ((mantissa2 / FLOAT_FACTOR) + mantissa1) / FLOAT_FACTOR;
value = ldexp (value, exponent);
/* Put the double into the requested memory location. */
*(double*)d = value;
memcpy (d, &value, sizeof (double));
break;
}