diff options
author | simonm <unknown> | 1999-02-22 10:51:18 +0000 |
---|---|---|
committer | simonm <unknown> | 1999-02-22 10:51:18 +0000 |
commit | 91b0770d32f28b617606c18b094191c06b1421ec (patch) | |
tree | a7abda46e432bbe5febb089662ef7a298b0c5990 /ghc | |
parent | 114da3533f3e9cdfbd7ed4b248a5b8750f22b0bd (diff) | |
download | haskell-91b0770d32f28b617606c18b094191c06b1421ec.tar.gz |
[project @ 1999-02-22 10:51:18 by simonm]
- Fix off-by-one in __encodeFloat;
- Tidy up __encodeDouble a bit.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/rts/StgPrimFloat.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/ghc/rts/StgPrimFloat.c b/ghc/rts/StgPrimFloat.c index 2a73977927..dad2350e38 100644 --- a/ghc/rts/StgPrimFloat.c +++ b/ghc/rts/StgPrimFloat.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgPrimFloat.c,v 1.4 1999/02/18 12:26:12 simonm Exp $ + * $Id: StgPrimFloat.c,v 1.5 1999/02/22 10:51:18 simonm Exp $ * * (c) The GHC Team, 1998-1999 * @@ -51,13 +51,8 @@ __encodeDouble (I_ size, StgByteArray ba, I_ e) /* result = s * 2^e */ I_ i; /* Convert MP_INT to a double; knows a lot about internal rep! */ - i = __abs(size)-1; - if (i < 0) { - r = 0.0; - } else { - for (r = arr[i], i--; i >= 0; i--) - r = r * GMP_BASE + arr[i]; - } + for(r = 0.0, i = __abs(size)-1; i >= 0; i--) + r = (r * GMP_BASE) + arr[i]; /* Now raise to the exponent */ if ( r != 0.0 ) /* Lennart suggests this avoids a bug in MIPS's ldexp */ @@ -98,7 +93,7 @@ __encodeFloat (I_ size, StgByteArray ba, I_ e) /* result = s * 2^e */ I_ i; /* Convert MP_INT to a float; knows a lot about internal rep! */ - for(r = 0.0, i = __abs(size); i >= 0; i--) + for(r = 0.0, i = __abs(size)-1; i >= 0; i--) r = (r * GMP_BASE) + arr[i]; /* Now raise to the exponent */ |