liveBook · Manning

BigDecimal

BigDecimal is a Java standard-library class representing immutable, arbitrary-precision signed decimal values.

How 2 Manning books explain it

Spring Start Here, Second Edition

BigDecimal is a Java numeric type that represents decimal values with arbitrary precision and is suitable for exact monetary calculations.

How it is used
Protects precision when representing sensitive decimal values such as purchase prices.
How deep it goes
Explains precision-loss rationale and price-field use, but does not develop BigDecimal arithmetic.
Examples
Uses a purchase model’s price field and database row mapping as examples.
What you can do after
Apply BigDecimal instead of double or float when modeling prices that need decimal precision.

Read how Spring Start Here, Second Edition explains BigDecimal →

100 Java Mistakes and How to Avoid Them

BigDecimal is the Java arbitrary-precision decimal numeric class in java.math.

How it is used
Represents precise decimal values and exposes comparison rules that avoid scale-related equality errors.
How deep it goes
Explains arbitrary precision, unscaled values, scale, equality behavior, remedies, and an IntelliJ inspection limitation.
Examples
Demonstrates long-to-double precision loss and BigDecimal values constructed from "0" and "0.0".
What you can do after
Diagnose scale-sensitive equality and choose compareTo() or stripTrailingZeros() for the intended comparison.

Read how 100 Java Mistakes and How to Avoid Them explains BigDecimal →

Also covered in

What to know first

Related concepts

Questions about BigDecimal

What is BigDecimal?

BigDecimal is a Java standard-library class representing immutable, arbitrary-precision signed decimal values.

Which Manning books explain BigDecimal?

Spring Start Here, Second Edition and 100 Java Mistakes and How to Avoid Them.

What should I know before learning BigDecimal?

Manning books that teach BigDecimal usually introduce float64 and floating-point arithmetic first.

What is the difference between BigDecimal and floating-point arithmetic?

BigDecimal is a Java standard-library class representing immutable, arbitrary-precision signed decimal values. Floating-point arithmetic is numerical computation using finite-precision representations of real numbers, which can introduce rounding and range errors.

What are the parts of BigDecimal?

BigDecimal includes scale and unscaled value.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.