mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Added BigDecimal float constructor caveat
This commit is contained in:
parent
edfc99e198
commit
f7af2da9db
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user