BigDecimal.fromDouble constructor
BigDecimal.fromDouble(
- double value
Creates a BigDecimal from a double value.
value
the double value
A wrapper class for precise decimal arithmetic.
This class provides arbitrary precision decimal arithmetic similar to Java's BigDecimal. It uses Dart's built-in support for arbitrary precision integers and implements decimal arithmetic on top of it.
Example usage:
BigDecimal a = BigDecimal("123.456");
BigDecimal b = BigDecimal("78.9");
BigDecimal sum = a + b;
print(sum.toString()); // "202.356"
print(sum.setScale(2)); // "202.36" (rounded)
Implementation
factory BigDecimal.fromDouble(double value) {
return BigDecimal(value.toString());
}