Crate bigdecimal [−] [src]
A Big Decimal
BigDecimal allows storing any real number to arbitrary precision; which avoids common floating point errors (such as 0.1 + 0.2 ≠ 0.3) at the cost of complexity.
BigDecimal uses a
BigInt object, paired with a 64-bit
integer which determines the position of the decimal point. Therefore,
the precision is not actually arbitrary, but limitied to 263 decimal
Common numerical operations are overloaded, so we can treat them the same way we treat other numbers.
It is not recommended to convert a floating point number to a decimal directly, as the floating point representation may be unexpected.
A big decimal type.