Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More precise bounds for of_float conversion to small ints (#137)
This patch improves the bounds used in of_float to decide whether the double can fit into an OCaml 63-bit tagged int. The upper bound is 0x3ffffffffffffe00, which is exactly representable as a double (2^53-1)*2^9 = (2-2^-52) * 2^61 as it is 1.1...1 * 2^61 with 52 ones after the 1, and is less than 2^62, so it is representable as an OCaml int. The double just after 0x3ffffffffffffe00 is 0x4000000000000000, or 2^62, which does not fit an OCaml int. For the lower bound, -0x4000000000000000 is exactly representable as a double, but also the smallest number that fits an OCaml int.
- Loading branch information