Hello Simon, thanks for catching that! It certainly wasn't my intention to introduce any new C language requirements, and in this case it's also not quite the right thing to do to begin with: we want to print IEEE 754 floats with the right precision, no matter what our host floating-point format is. Unfortunately, I can't find a way to do that, thus the DECIMAL_DIG usage. I'm attaching a patch to use a fixed value of 17, which is the right thing to do for a 52-bit mantissa. It still won't do the right thing on hosts whose double type is insufficient to represent IEEE 754 doubles. Suggested change log entry: opcodes/: 2017-04-06 Pip Cet * wasm32-dis.c (print_insn_wasm32): Use a fixed value (valid for IEEE 754 doubles) instead of DECIMAL_DIG. diff --git a/opcodes/wasm32-dis.c b/opcodes/wasm32-dis.c index 80e4ffe81a..f150163a80 100644 --- a/opcodes/wasm32-dis.c +++ b/opcodes/wasm32-dis.c @@ -23,13 +23,22 @@ #include "opintl.h" #include "safe-ctype.h" #include "floatformat.h" -#include #include "libiberty.h" #include "elf-bfd.h" #include "elf/internal.h" #include "elf/wasm32.h" #include +/* Number of decimal digits, n, such that any floating-point number in the + widest supported floating type with pmax radix b digits can be rounded + to a floating-point number with n decimal digits and back again without + change to the value, + + pmax * log10(b) if b is a power of 10 + ceil(1 + pmax * log10(b)) otherwise +*/ +#define DECIMAL_DIG_IEEE754 17 + /* Type names for blocks and signatures. */ #define BLOCK_TYPE_NONE 0x40 #define BLOCK_TYPE_I32 0x7f @@ -405,7 +414,7 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info) if (ret < 0) return -1; len += ret; - prin (stream, " %.*g", DECIMAL_DIG, fconstant); + prin (stream, " %.*g", DECIMAL_DIG_IEEE754, fconstant); break; case wasm_constant_f64: @@ -413,7 +422,7 @@ print_insn_wasm32 (bfd_vma pc, struct disassemble_info *info) if (ret < 0) return -1; len += ret; - prin (stream, " %.*g", DECIMAL_DIG, fconstant); + prin (stream, " %.*g", DECIMAL_DIG_IEEE754, fconstant); break; case wasm_call: