Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
issues with caml_float_of_hex #7690
Original bug ID: 7690
There are some overflow issues with the exponent computations in caml_float_of_hex, which results in some invalid conversions. The integer exp variable overflows, which results in the call to ldexp to overflow when it should underflow (and vice versa).
The test "if (e < INT_MIN || e > INT_MAX) return -1;" is ineffective on Win64 since int and long have the same size there: this results in some difference in behavior between win64 and linux.
And (minor point), the function accept spaces between the 'p' and the exponent digits, whereas strtod and the C99 syntax do not allow spaces there.
Steps to reproduce
$ cat f.ml
let () =
$ ocamlopt.opt f.ml
$ ./a.out 0x1.0p-2147483648
$ ./a.out 0x123456789ABCDEF0p2147483647
$ ./a.out 0x1p2147483648
$ ./a.out '0x1p 1'