ddn.columnar.decimal

The decimal-column layer of ddn.df (ADR-2026-10-23-13/-14): exact fixed-point values stored as raw coefficients (int64 for precision <= 18, Int128 payload for 38), semantics from ddn.num.fixed_decimal - never a FLOAT64 detour. Casts to/from STRING and INT are exact (inexact throws); FLOAT64 only explicitly. Comparisons align scales internally; same-dtype add/subtract exact; overflow throws.

Types 2

aliasDecimalCoeff = long

The decimal coefficient's storage: int64 for precision <= 18, a two-int64 payload for 38. The column's precision/scale live in the dtype metadata, not per value.

Builds one DECIMAL chunk from int64 coefficients at a fixed scale. Values are coefficient * 10^-scale; nulls are validity-0.

Fields
private DecimalCoeff[] _coeffs
private ulong[] _validity
private size_t _length
private bool _anyNull
private bool _sealed
Methods
void append(DecimalCoeff v) @safe pure nothrowAppends one coefficient (the caller manages the scale).
void appendNull() @safe pure nothrowAppends a null.
private void setValid(size_t i, bool v) @safe pure nothrow
ArrayData finish(ubyte precision, ubyte scale) @safeSeals the chunk.
private size_t countValid() @safe pure nothrow

Functions 21

fnlong parseDecimalCoeff(scope const(char)[] text, ubyte scale) @safeParses a decimal string into a coefficient at the given scale. Exact: trailing digits beyond `scale` that are nonzero throw.
fnstring renderDecimal(long coeff, ubyte scale) @safe pure nothrowRenders a coefficient at the given scale as decimal text.
fnSeries decimalFromString(string name, ubyte precision, ubyte scale, Nullable!(string)[] values)Builds a DECIMAL Series from decimal strings, parsed exactly.
fnlong[2] alignScales(long a, ubyte aScale, long b, ubyte bScale) @safeAligns two coefficients to a common scale (the max), returning the aligned pair. The one with the smaller scale is scaled up.
fnSeries decimalFromCoeffs(string name, ubyte precision, ubyte scale, Nullable!long[] coeffs)Builds a DECIMAL Series from raw int64 coefficients at a fixed precision/scale (values are `coefficient * 10^-scale`). The exact constructor for tests and benchmarks; `decimalFromString` parses dec...
fnbool decimalEq(long a, ubyte aScale, long b, ubyte bScale) @safe pure nothrowValue-based equality of two coefficients at their own scales: the smaller scale aligns up; an alignment overflow means the values differ (one magnitude cannot be the other's). Exact - never a FLOAT...
fnint decimalCmp(long a, ubyte aScale, long b, ubyte bScale) @safe pure nothrowThe value-based three-way comparison of two coefficients at their own scales (the total order sort and min/max ride): negative when `a < b`, zero when equal, positive when `a > b`. An alignment ove...
fnsize_t decimalHash(long coeff, ubyte scale) @safe pure nothrowThe canonical value hash: trailing zero digits divide out of the coefficient while the effective exponent drops, so equal values at different scales hash equal (`1.10` and `1.1`); zero hashes equal...
fnSeries decimalArith(string op)(Series a, Series b)Same-dtype exact addition/subtraction of DECIMAL columns: one checked step per slot (overflow throws before any result is exposed), nulls propagate, the dtype is unchanged. Multiply, divide and cro...
private fnlong checkedAdd(long a, long b) @safe pure
private fnlong checkedSub(long a, long b) @safe pure
fnSeries decimalNegate(Series a)Exact negation: every valid slot negates with the `long.min` overflow check.
private fnArrayData retag(ArrayData chunk, DataType dtype) @trusted pure nothrow
fnArrayData decimalSumSlot(Series s)The exact checked sum as a one-slot DECIMAL chunk: the chunk- ordered serial left fold with a per-step overflow check (the same association the INT64 sum keeps, plus exactness).
fnSeries decimalGroupAgg(string agg)(string outName, Series col, size_t[][] groupRows)The per-group decimal aggregation over group row lists: sum (the checked row-order fold), min/max (coefficient compare - one scale per column), first/last (the first/last row when valid, else null)...
fnSeries decimalCastFrom(Series s, DataType target, bool strict)Casts a DECIMAL Series to its admitted targets: STRING renders exactly; the integer kinds keep exact values only (a nonzero fraction or an out-of-range quotient is a failure); FLOAT32/64 compute `c...
private fnbool intFits(DataType target, long q) @safe pure nothrow
private fnSeries decimalIntBuild(Series s, DataType target, long div)
private fnSeries buildInt(T)(Series s, long div, DataType target)
fnSeries decimalCastTo(Series s, DataType target, bool strict)Casts a flat Series into a DECIMAL column at the target's precision/scale: STRING parses exactly (inexact or malformed is a failure); the integer kinds multiply up with the overflow check; FLOAT32/...
private fnptrdiff_t indexOf(scope const(char)[] s, char c) @safe pure nothrow