summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2017-04-05 21:47:20 -0700
committerH. Peter Anvin <hpa@zytor.com>2017-04-05 21:47:20 -0700
commit3646e7dde050c06101d1b1bb4dd4f944354777de (patch)
treeebfbaaa7dbaf8fbd9a840aa78f6d4c750cb35345
parent90cc4154ae1dd5152ba0c3a47ab8ae357fd0530a (diff)
downloadnasm-3646e7dde050c06101d1b1bb4dd4f944354777de.tar.gz
BR 3392399: float: get rid of bogus exponent calculation
It turns out that the calculation of "twopwr" in ieee_flconvert_bin() was more complex than necessary, and wrong in the case of a pure fraction. Reported-by: Roel <roelsuidgeest@zonnet.nl> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--asm/float.c4
-rw-r--r--test/hexfp.asm25
2 files changed, 27 insertions, 2 deletions
diff --git a/asm/float.c b/asm/float.c
index b35d7a5e..fd66ef38 100644
--- a/asm/float.c
+++ b/asm/float.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2017 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -545,7 +545,7 @@ static bool ieee_flconvert_bin(const char *string, int bits,
mp = mult;
ms = (LIMB_BITS-1)-l;
- twopwr = seendot ? twopwr-bits+l : l+1-bits;
+ twopwr += l+1-bits;
}
if (seendigit) {
diff --git a/test/hexfp.asm b/test/hexfp.asm
new file mode 100644
index 00000000..02c972f8
--- /dev/null
+++ b/test/hexfp.asm
@@ -0,0 +1,25 @@
+;; BR 3392399
+
+; All of these should be the same value...
+%macro fp 1
+ %1 0.5
+ %1 5e-1
+ %1 0x1.0p-1
+ %1 0x0.8p0
+ %1 0x0.8
+ %1 0x8p-4
+ %1 0x.8
+ %1 0x1p-1
+ %1 0x0.1p3
+ %1 0x0.01p7
+ %1 0x0.01p7
+ %1 0x0.001p11
+
+%endmacro
+
+ fp do
+ fp dt
+ fp dq
+ fp dd
+ fp dw
+ fp dd