mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
([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:
parent
1381709a43
commit
fca7d27283
1 changed files with 7 additions and 5 deletions
|
@ -225,7 +225,8 @@ static int debug_binary_coder = 0;
|
||||||
volatile double value;
|
volatile double value;
|
||||||
int exponent, mantissa;
|
int exponent, mantissa;
|
||||||
short exponent_encoded;
|
short exponent_encoded;
|
||||||
value = *(float*)d;
|
|
||||||
|
memcpy (&value, d, sizeof (float));
|
||||||
/* Get the exponent */
|
/* Get the exponent */
|
||||||
value = frexp (value, &exponent);
|
value = frexp (value, &exponent);
|
||||||
exponent_encoded = exponent;
|
exponent_encoded = exponent;
|
||||||
|
@ -245,7 +246,8 @@ static int debug_binary_coder = 0;
|
||||||
volatile double value;
|
volatile double value;
|
||||||
int exponent, mantissa1, mantissa2;
|
int exponent, mantissa1, mantissa2;
|
||||||
short exponent_encoded;
|
short exponent_encoded;
|
||||||
value = *(double*)d;
|
|
||||||
|
memcpy (&value, d, sizeof (double));
|
||||||
/* Get the exponent */
|
/* Get the exponent */
|
||||||
value = frexp (value, &exponent);
|
value = frexp (value, &exponent);
|
||||||
exponent_encoded = exponent;
|
exponent_encoded = exponent;
|
||||||
|
@ -383,7 +385,7 @@ static int debug_binary_coder = 0;
|
||||||
{
|
{
|
||||||
short exponent;
|
short exponent;
|
||||||
int mantissa;
|
int mantissa;
|
||||||
double value;
|
volatile double value;
|
||||||
/* Decode the exponent and mantissa. */
|
/* Decode the exponent and mantissa. */
|
||||||
READ_SIGNED_TYPE (&exponent, short, ntohs);
|
READ_SIGNED_TYPE (&exponent, short, ntohs);
|
||||||
READ_SIGNED_TYPE (&mantissa, int, ntohl);
|
READ_SIGNED_TYPE (&mantissa, int, ntohl);
|
||||||
|
@ -391,7 +393,7 @@ static int debug_binary_coder = 0;
|
||||||
value = mantissa / FLOAT_FACTOR;
|
value = mantissa / FLOAT_FACTOR;
|
||||||
value = ldexp (value, exponent);
|
value = ldexp (value, exponent);
|
||||||
/* Put the double into the requested memory location as a float */
|
/* Put the double into the requested memory location as a float */
|
||||||
*(float*)d = value;
|
memcpy (d, &value, sizeof (float));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +410,7 @@ static int debug_binary_coder = 0;
|
||||||
value = ((mantissa2 / FLOAT_FACTOR) + mantissa1) / FLOAT_FACTOR;
|
value = ((mantissa2 / FLOAT_FACTOR) + mantissa1) / FLOAT_FACTOR;
|
||||||
value = ldexp (value, exponent);
|
value = ldexp (value, exponent);
|
||||||
/* Put the double into the requested memory location. */
|
/* Put the double into the requested memory location. */
|
||||||
*(double*)d = value;
|
memcpy (d, &value, sizeof (double));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue