<div dir="ltr">Hi!<div><br></div><div>I’m currently working on a project that heavily relies on float values, and we occasionally use BigDecimal for more precise mathematical operations. However, I’ve noticed that the current BigDecimal constructor implementation only supports double, which can lead to unintentional type conversion and precision loss when creating a BigDecimal from a float.<br><br>The documentation suggests using BigDecimal.valueOf(double val) as the preferred method for converting double or float values to BigDecimal, but since method takes double as an argument, it leads much more often to precision loss when float is passed.</div><div><br>For example:<br><br>- BigDecimal.valueOf(0.1d) correctly produces 0.1.</div><div><br>- However, BigDecimal.valueOf(0.1f) produces 0.10000000149011612, which introduces unwanted precision artifacts.</div><div><br>What would you think about introducing a static factory method specifically for float values, such as:<br><br>public static BigDecimal valueOf(float val) {<br>    return new BigDecimal(Float.toString(val));<br>}</div><div><br>This addition should improve usability and ensure that float values are handled more precisely within the BigDecimal API<br></div></div>