Sample
brick/math 0.19.1: Construct and convert BigRational fractions, handle non-terminating decimal conversions with toScale, and navigate asymmetric mixed-type arithmetic in brick/math
Verified sample for composer brick/math 0.19.1: Construct and convert BigRational fractions, handle non-terminating decimal conversions with toScale, and…
sha256:b39a510dfa2b50e48cb4d90b401409435dcc53ffa14bdcfd57e27be2fa382a1c
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
- Construct and convert BigRational fractions, handle non-terminating decimal conversions with toScale, and navigate asymmetric mixed-type arithmetic in brick/math
- Packages
- Symbols
-
- Brick\Math\BigRational::ofFraction
- Brick\Math\BigRational::toBigDecimal
- Brick\Math\BigRational::toScale
- Brick\Math\BigRational::power
- Environment
- php
- Created
- 2026-08-16T08:29:22Z
Contract
- BigRational::of(1, 3) takes only 1 argument and silently evaluates to 1/1; fractions require ofFraction(1, 3) or of('1/3')
- BigRational::ofFraction(2, -4) eagerly normalizes to -1/2 with strictly positive BigInteger denominator
- BigRational::ofFraction(1, 0) throws brick/math's DivisionByZeroException implementing MathException, not native DivisionByZeroError
- toBigDecimal() on non-terminating rational 1/3 throws RoundingNecessaryException; terminating 1/4 returns 0.25
- toScale(2) on 1/3 without RoundingMode defaults to Unnecessary and throws; explicit RoundingMode produces 0.33
- BigRational::plus(BigInteger) succeeds (1/3 + 5 = 16/3), but BigInteger::plus(BigRational) and BigDecimal::plus(BigRational) throw RoundingNecessaryException
- BigRational::power(-2) inverts and exponentiates ((2/3)^-2 = 9/4), while BigInteger::power(-2) and BigDecimal::power(-2) throw InvalidArgumentException
Files
- NOTES.md
- composer.json
- composer.lock
- csx.json
- src/RationalHelper.php
- test/contract.php