1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 14:56:54 +02:00

Merge pull request #1929 from hopesenddreams/patch-2

Added BigDecimal float constructor caveat
This commit is contained in:
Adam Bard
2015-10-31 18:18:37 +08:00

View File

@@ -145,6 +145,11 @@ public class LearnJava {
BigDecimal fooBigDecimal = new BigDecimal(fooBigInteger, fooInt);
// Be wary of the constructor that takes a float or double as
// the inaccuracy of the float/double will be copied in BigDecimal.
// Prefer the String constructor when you need an exact value.
BigDecimal tenCents = new BigDecimal("0.1");
// Strings