Day118 — BigDecimal

Jacky Tsang
1 min readOct 28, 2019

--

BigDecimal is immutable, arbitrary-precision signed decimal numbers

Need Of BigDecimal

The two java primitive types(double and float) are floating point numbers, which is stored as a binary representation of a fraction and a exponent.

Other primitive types(except boolean) are fixed-point numbers. Unlike fixed point numbers, floating point numbers will most of the times return an answer with a small error (around 10^-19) This is the reason why we end up with 0.009999999999999998 as the result of 0.04–0.03 in the above example.

Check if BigDecimal is equal to 0

--

--

No responses yet