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: