precise_decimal 0.0.1
precise_decimal: ^0.0.1 copied to clipboard
Arbitrary-precision decimal arithmetic for Dart, built toward full General Decimal Arithmetic (GDA) compliance.
Changelog #
Unreleased #
Breaking changes (pre-release API cleanup) #
This package has not yet been published. The items below are intentional pre-release API improvements. Adapt to the new names before the first published release.
Exception hierarchy
- Added shared
BigDecimalExceptionsealed base interface. CatchBigDecimalExceptionto handle any package error uniformly. BigDecimalParseExceptionnow extendsFormatExceptionand implementsBigDecimalException, satisfying both Dart parse conventions and the package-specific catch surface.BigDecimalConversionExceptionnow extendsBigDecimalExceptiondirectly.BigDecimalArithmeticExceptionis now a non-finalclass so subtypes (BigDecimalOverflowException,BigDecimalSignalException) can extend it.- Removed
BigDecimalFormatException(old name). UseBigDecimalParseException. BigDecimalSignalExceptionnow requires an explicitmessageargument; previously the message defaulted to the condition GDA name.
Context-sensitive arithmetic — split trapping / result API
All context-sensitive arithmetic operations follow a consistent two-method
pattern. The base method is the trapping path; the *Result companion is the
non-trapping, condition-returning path.
| Trapping method | Non-trapping companion | Notes |
|---|---|---|
add(other, context) |
addResult(other, context) |
add(other) without context is still exact |
subtract(other, context) |
subtractResult(other, context) |
same |
multiply(other, context) |
multiplyResult(other, context) |
same |
divide(divisor, context: ...) |
divideResult(divisor, context: ...) |
divideToScale(...) is the fixed-scale form |
roundWithContext(context) |
roundResult(context) |
uses reserved name round for decimal-places alias |
setScale(…) |
setScaleResult(…) |
non-context; returns emitted conditions |
- Removed
multiplyWithContext(other, context). Replace withmultiply(other, context)(trapping) ormultiplyResult(other, context)(non-trapping). add,subtract, andmultiplynow each accept an optional[DecimalContext? context]parameter. Calling them without a context performs exact arithmetic as before, with no behaviour change.- Added
DecimalOperationResult<T>as a public type. It carriesvalue,conditions,hasCondition(condition), andvalueOrThrow(context).
0.0.1 #
- Initial version.