@decimal.Decimal
This page tracks the current repository implementation and is written as the 0.2.0 API baseline.
Representation
Finite values are stored as:
coefficient * 10^exponent10
with an attached working precision.
Constructors and Parsing
Decimal::makeDecimal::zeroDecimal::oneDecimal::infDecimal::nanDecimal::from_intDecimal::from_bigintDecimal::from_floatDecimal::from_doubleDecimal::from_stringDecimal::from_bin_float
Notes:
- Finite public constructors normalize by removing removable powers of
10. from_stringaccepts plain decimal and scientific notation.- Invalid strings return
None.
Access, Normalization, and Comparison
classifyprecisionsigncoefficientexponent10is_zeronormalizedwith_precisioncompareminmaxclamp
Notes:
compareaborts onNaN.clampaborts if the bounds are unordered orNaN.
Arithmetic and Conversion
negabsaddsubmuldivto_bin_float
Supported operators:
+-*/- unary
-
Conversion notes:
- Decimal-to-binary conversion may be approximate for non-dyadic values.
- Binary-to-decimal conversion is exact for the currently stored finite
BinFloatvalue.
Trait Surface
Decimal currently implements:
@def.Floating@arithmetic.ParseChecked@arithmetic.SqrtChecked@arithmetic.DivChecked@arithmetic.CompareChecked@arithmetic.PowNatChecked@arithmetic.PowIntCheckedEq,Add,Sub,Mul,Div,Neg,Show
Behavior note:
- This pass does not expose transcendental or constant traits from
Decimal. - Checked arithmetic is the intended integration surface with
Luna-Flow/arithmetic.