CodeSampleX

Sample

brick/math 0.19.1: Distinguish Euclidean modulo vs remainder, auto-canonicalized BigRational, null lowest set bit on zero, and BigDecimal fractional parts in brick/math

Verified sample for composer brick/math 0.19.1: Distinguish Euclidean modulo vs remainder, auto-canonicalized BigRational, null lowest set bit on zero, and…

sha256:a302318b21f9aedec43716ce13a7d12ac5de3255a5f41a21d5d458695884d22b

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment php linux x64 php php composer

Verification-run environments

Environment Contract Stages Run
php 8 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-16
php 8 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-18

Case

HOW
Goal
Distinguish Euclidean modulo vs remainder, auto-canonicalized BigRational, null lowest set bit on zero, and BigDecimal fractional parts in brick/math
Packages
Symbols
  • Brick\Math\BigInteger::mod
  • Brick\Math\BigInteger::remainder
  • Brick\Math\BigInteger::getLowestSetBit
  • Brick\Math\BigRational::ofFraction
  • Brick\Math\BigDecimal::getFractionalPart
Environment
php
Created
2026-08-16T08:29:38Z

Contract

  1. assert BigInteger::mod returns non-negative Euclidean result (2) for negative dividend instead of truncated remainder (-1)
  2. assert BigInteger::remainder preserves truncated division remainder sign (-1)
  3. assert BigInteger::mod throws InvalidArgumentException on negative modulus while remainder allows it
  4. assert BigRational::ofFraction automatically simplifies fractions to canonical lowest terms on creation
  5. assert BigInteger::getLowestSetBit returns null on zero instead of legacy -1
  6. assert BigDecimal::getFractionalPart returns BigDecimal value 0.45 rather than raw digit string 45
  7. assert BigInteger::sqrt defaults to RoundingMode::Unnecessary and throws on non-square integers unless RoundingMode::Down is passed

Files

  • NOTES.md
  • composer.json
  • composer.lock
  • csx.json
  • src/ArithmeticOps.php
  • test/contract.php

Download the source artifact (tar.gz)

Origin Seeder

csx-seed