Fix Decimal quotient finalization and boolean tuple digits
Finalize Decimal integer quotients against the context in //, Context.divide_int, and both divmod entry points. With prec=28 and Emax=10, dividing Decimal('1e20') by Decimal(1) previously returned a finite value without overflow signals; it now returns Infinity or raises Overflow according to the traps. Clamping and rounding also follow the context, while remainders are preserved.
Accept boolean coefficient digits in tuple-form Decimal construction: Decimal((0, (True,), 0)) now returns Decimal(1), matching CPython. Regression tests cover both signs, overflow rounding and traps, clamping and traps, preserved remainders, boolean digits, and rejection of invalid digits.
Validation:
- All 16 Decimal comparisons against Monty and CPython 3.14.2 pass with
memory-model-checksenabled (cargo run -p monty-datatest --features memory-model-checks -- decimal). cargo clippy -p monty --lib --features memory-model-checks -- -D warningspasses.- Ruff lint/format, Rust formatting, and
git diff --checkpass.
Summary by cubic
Fixes two Decimal compatibility gaps: integer quotients are now finalized against the context, and tuple-form Decimal construction accepts booleans as coefficient digits.
//,Context.divide_int, and bothdivmodentry points now apply exponent checks, clamping, and rounding to the quotient, while preserving the exact remainder.- With
prec=28andEmax=10,Decimal('1e20') // Decimal(1)previously returned a finite value without overflow signals; it now returnsInfinityor raisesOverflowaccording to traps. Decimal((0, (True,), 0))now returnsDecimal(1), matching CPython.- Regression tests cover overflow, clamping, traps, preserved remainders, boolean digits, and rejection of invalid digits.