On Wed, 19 Jun 2024 14:22:38 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
wrote:

> Take the `double` closest to the exact decimal 0.1.
> 
> My understanding is that IEEE with a precision of 17 would convert it to the 
> decimal 0.10000000000000001.
> 
> However, `Formatter` with a specifier `"%.17f"` will render this as 
> 0.10000000000000000. That's because `Formatter`'s spec is based on this 
> method (which produces 0.1), so cannot generate the trailing 1.
> 
> Similarly, the `double` closest to 1.2 is converted to 1.19999999999999996 by 
> IEEE and to 1.20000000000000000 by `Formatter`, because this method produces 
> 1.2.
> 
> In other words, neither this method nor the functionality offered by 
> `Formatter` and friends correspond to IEEE, at least not in full.

Updated to use a conversion through BigDecimal.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19590#discussion_r1676965169

Reply via email to