number: Decimal that computes #34
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Decimalis declared and planned; 1.0 cannot promise a declaration that answers "not implemented". Database drivers need it fornumeric/DECIMAL/Decimal128. This is the epic; the specification is docs/design/DECIMAL.md (section 14 lists the slices).Source
Steps (one PR each, in this order; this issue does not carry
readyitself)DECIMAL.mdtorb_decimal_*,Rounding, the std surface ofstd/number, nativesReadyEncodedValue.Exact, exact JSON/YAML/TOML round trip,decimal-encodingconformance program, statuses and docs from "planned" to "stable"Done when
mainCI is green:Decimalarithmetic, comparison,Show, text conversion andEncode/Decoderun in both back ends,compiler/src/backend/c/natives.trbhas no plannedDecimalentry, conformance programsdecimal-arithmetic,decimal-literals,decimal-encodingpass with identical output in VM and native.Notes
Seed: none of the steps adds a syntax form or a name the compiler looks up (DECIMAL.md section 10; #336 re-checks with
torb ir --statistics .). Database drivers (SqlValue.Numeric, Postgres/MySQL/BSON) are not part of this epic; they belong to the driver issues that useDecimal.Moved from the planning lists of the docs; the design record stays the specification.
[loop:torbscript] intake: in scope as an issue (author orion, label loop), with an owner question: a computing
Decimalis a numeric design choice (precision model, rounding, scale, representation) that must be fixed in a design record first. Large; touches natives, checker and both back ends, probably the seed. To be filed as owner decision in refine. Release freeze for 0.1.0 (2026-10-06) holds new PRs, next: refine (owner decision expected)[loop:torbscript] refine: still queued behind the intake order. next: waiting (ready buffer full: #4, #163, #164, #223 are ready) until 2026-10-10T04:00:00Z
[loop:torbscript] claim refine by session:loop-torbscript-20261012 until 2026-10-12T15:14Z
torb_decimal_*) and ready natives #334Decimal#335Exactand conformance programs #336[loop:torbscript] decided by the loop:
Decimalis a numeric design choice inside the language, not an owner category (no public commitment, cost, product direction or breaking change: the type is declared but has never run). Decisions, to be written intodocs/design/DECIMAL.mdby #332:Int32scale (value = unscaled / 10^scale), like JavaBigDecimal/ Pythondecimal, so postgresnumeric, mysqlDECIMALandDecimal128all fit without loss. Runtime layout: sign, base-10^9 limbs, scale; heap value owned by the runtime (the IR already lays outDecimalNumberas a runtime kind).+ - *are exact (scale of the sum is the larger scale, of the product the sum of scales). Overflow of the scale (Int32) or of memory panics./rounds to 34 significant digits (theDecimal128precision), half-even, and panics on division by zero likeInt(PANICS.md);%is the truncated remainder with the sign of the dividend (as forInt).divided(by:, scale:, rounding:)androunded(scale:, rounding:)take an explicit rounding mode (HalfEven,HalfUp,Down,Up,Floor,Ceiling).1.0 == 1.00),compareandhashconsistent with it (hash of the normalised form).Showkeeps the scale (19.90stays19.90), no exponent form,-0.00shows as0.00.TryFrom<String>reads an optional sign, digits with an optional., optionaleexponent; refusesnan,inf, underscores and whitespace withNumberParseError.Float64; conversion fromFloatis an explicit fallibletryFrom(refuses non-finite), toFloatexplicit and rounded.Decimaland the natives are already declared (manifest entries change from planned to ready). The implementer re-checks.Encode/DecodeExact, conformance programs.#34 stays the umbrella and is closed when #336 lands; it does not carry
readyitself.torb_decimal_*) and ready natives #334Decimal#335Exactand conformance programs #336[loop:torbscript] refine: split into #332 (ready), #334, #335, #336, all linked and ordered, next: waiting (dependency #332 .. #336; #34 closes with #336). Tokens used by this worker: about 90k.
[loop:torbscript] claim refine by session:loop-torbscript-20261028 until 2026-10-28T15:30Z
[loop:torbscript] decided by the loop: #34 stays the epic and does not carry
ready; the work is done up to #335 (merged), so only #336 is left. Checked againstmain(2026-10-28): the std surface listed in #336 (rounded,divided,scale,normalized,unscaledText,Decimal.of,from/tryFromconversions,Float64.from(Decimal)), the natives (noDecimalentryPlannedany more) and the conformance programsdecimal-arithmetic/decimal-literalsare in. What really remains is the encoding side (EncodedValue.Exact, exact JSON reading) and the status flips in the docs. #336 is narrowed to exactly that and setready(one PR, two commits, no new issue needed). Decisions recorded there:ExactafterFloat; a JSON number token staysFloatwhen printing the parsedFloat64returns the token and becomesExactotherwise (existing tests keep their shape, aDecimalfield never loses digits, no extra Decimal parse for ordinary floats); TOML keeps the string form because the format has no decimal type. No owner decision needed: no public commitment, cost, product direction or published-contract change. Seed: none expected, the compiler findsEncodedValuecases by name, so a new case is additive.Exactand conformance programs #336[loop:torbscript] refine: #34 reduced to an epic checklist (#332, #334, #335 done; #336 is the last step), #336 rewritten to the definition of ready and labelled
ready; no new issue (duplicate check: only #336 matches), no owner question. Tokens used by this worker: about 150k. next: waiting (epic: #336 is ready for implementation; #34 closes when #336 lands)[loop:torbscript] close: #336 is closed (PR #544 landed as
9e774663); closing #34 needsmainCI green on a landed commit, andmain(b471d025, with the budget fix of PR #556) is still running its push checks. next: waiting (main CI green onb471d025, then close #34)[loop:torbscript] close: main CI is green on
38d3edd4(38d3edd4ab), which contains the landed work of #336 (PR #544,9e774663) and the budget fixb471d025. All steps of the epic are done. Closing.