Adding BigDecimal.valueOf(float val) constructor
Joseph D. Darcy
joe.darcy at oracle.com
Thu Jan 23 23:59:16 UTC 2025
On 1/23/2025 2:35 PM, Remi Forax wrote:
> Hello Jan,
> what you are suggesting is not a backward compatible change.
There is a source compatibility impact, meaning that for some call
sites, the mapping of existing code using BigDecimal before and after
the addition of the overloaded method would change. That wouldn't
necessarily preclude us from making such a change (and such changes have
been made in the past), but extra caution and analysis would be called for.
Cheers,
-Joe
>
> If we add BigDecimal,valueOf(float), then a program recompiled with
> the new JDK may change its behavior,
> you can think that the new behavior is more "correct" that the current
> one, but changing the behavior of existing programs is usually a big
> NO ! in Java.
>
> Also, I believe that the reason there is no such factory method that
> takes a float is that doing computations on floats is not recommanded,
> it becomes a mess rapidly of the imprecision of the float32
> representation, .
> For the same reason, in Java, 2.0 is a double and there is no
> FloatStream while there is a DoubleStream.
>
> regards,
> Rémi
>
> ------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250123/932899e8/attachment-0001.htm>
More information about the core-libs-dev
mailing list