From a449b8c0878cf970c5112870df2a80c21bd5bb20 Mon Sep 17 00:00:00 2001 From: mccallum Date: Thu, 31 Oct 1996 20:47:42 +0000 Subject: [PATCH] ([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 --- Source/BinaryCStream.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/BinaryCStream.m b/Source/BinaryCStream.m index 0db07ec8b..de6248548 100644 --- a/Source/BinaryCStream.m +++ b/Source/BinaryCStream.m @@ -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; }