Skip to content

Commit 26848a7

Browse files
committed
8358804: Improve the API Note of BigDecimal.valueOf(double)
Reviewed-by: bpb, darcy, iris
1 parent 0e725c6 commit 26848a7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/java.base/share/classes/java/math/BigDecimal.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,10 +1372,15 @@ static BigDecimal zeroValueOf(int scale) {
13721372
* by the {@link Double#toString(double)} method.
13731373
*
13741374
* @apiNote This is generally the preferred way to convert a
1375-
* {@code double} (or {@code float}) into a {@code BigDecimal}, as
1375+
* {@code double} into a {@code BigDecimal}, as
13761376
* the value returned is equal to that resulting from constructing
13771377
* a {@code BigDecimal} from the result of using {@link
13781378
* Double#toString(double)}.
1379+
* <p>
1380+
* While a {@code float} argument {@code v} can be passed to this method,
1381+
* the result often contains many more trailing digits than the precision
1382+
* of a {@code float}.
1383+
* Consider using {@code new BigDecimal(Float.toString(v))} instead.
13791384
*
13801385
* @param val {@code double} to convert to a {@code BigDecimal}.
13811386
* @return a {@code BigDecimal} whose value is equal to or approximately

0 commit comments

Comments
 (0)