mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-04 13:50:55 +00:00
([BinaryCStream -encodeValueOfCType:at:withName:name]): Use
intermediate float value. ([BinaryCStream -decodeValueOfCType:at:withName:]): Likewise. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1920 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
32b96974b1
commit
a449b8c087
1 changed files with 6 additions and 2 deletions
|
@ -222,11 +222,13 @@ static int debug_binary_coder = 0;
|
|||
|
||||
case _C_FLT:
|
||||
{
|
||||
float fvalue;
|
||||
double value;
|
||||
int exponent, mantissa;
|
||||
short exponent_encoded;
|
||||
|
||||
memcpy (&value, d, sizeof (float));
|
||||
memcpy (&fvalue, d, sizeof (float));
|
||||
value = fvalue;
|
||||
/* Get the exponent */
|
||||
value = frexp (value, &exponent);
|
||||
exponent_encoded = exponent;
|
||||
|
@ -386,6 +388,7 @@ static int debug_binary_coder = 0;
|
|||
short exponent;
|
||||
int mantissa;
|
||||
double value;
|
||||
float fvalue;
|
||||
|
||||
/* Decode the exponent and mantissa. */
|
||||
READ_SIGNED_TYPE (&exponent, short, ntohs);
|
||||
|
@ -394,7 +397,8 @@ 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 */
|
||||
memcpy (d, &value, sizeof (float));
|
||||
fvalue = value;
|
||||
memcpy (d, &fvalue, sizeof (float));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue