summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndy <andrewgallasch@gmail.com>2015-10-31 18:31:51 +1030
committerAndy <andrewgallasch@gmail.com>2015-10-31 18:31:51 +1030
commitf7af2da9dbb504377c2ff7c2f29a55b9f363a4c1 (patch)
tree3e291442d525b4666cbd5099ddb658cd807e2ce1
parentedfc99e198fd2e87802ea81d6779fbadfab64919 (diff)
Added BigDecimal float constructor caveat
-rw-r--r--java.html.markdown7
1 files changed, 6 insertions, 1 deletions
diff --git a/java.html.markdown b/java.html.markdown
index 1813f81c..d7d0199b 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -144,7 +144,12 @@ public class LearnJava {
// or by initializing the unscaled value (BigInteger) and scale (int).
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