Contributions are welcome. Bug reports, performance improvements, and quality enhancements are particularly valued.
swift build # Debug build
swift test # Run all tests (541 tests across 14 suites)
cd Benchmarks && swift package benchmark # Run benchmark suite (release build)- All tests pass —
swift testmust be green. - Benchmarks checked — If your change touches arithmetic, rounding, or conversions, run
cd Benchmarks && swift package benchmarkbefore and after. Include the comparison in your PR description. Do not submit performance changes that show no improvement. - Lint clean — Run
swiftlintlocally. The project has a.swiftlint.ymlconfiguration with zero violations. - Focused scope — One concern per PR. Bug fix, feature, or refactor — not all three.
Tests use the Swift Testing framework (@Test macro, #expect() assertions). Test files are in Tests/FixedPointDecimalTests/ and cover:
ArithmeticTests.swift— Addition, subtraction, multiplication, division, remainderBasicTests.swift— Initialization, NaN, special values, propertiesCodableTests.swift— JSON encoding/decoding, multi-format inputComparisonTests.swift— Ordering, equality, hashingConversionTests.swift— Double, Decimal, Int conversions, float literal precisionEdgeCaseTests.swift— Boundary conditions, max/min, overflow boundariesFormatStyleTests.swift— FormatStyle, currency, locale formattingOverflowTests.swift— Wrapping, reporting, trapping overflowPowTests.swift— Integer exponentiation, positive/negative exponents, edge casesPreconditionTests.swift— Precondition trap validationPropertyTests.swift— Randomized property-based tests (commutativity, identity, parity with Decimal)RoundingTests.swift— All 6 rounding modes, scale values, edge casesStringTests.swift— Parsing, formatting, round-trips
Run a specific test suite:
swift test --filter RoundingTestsFuzz testing uses libFuzzer (Linux only, requires open-source Swift toolchain):
bash Fuzz/run.sh run -max_total_time=60All public APIs must have DocC documentation (/// comments). Include:
- A summary line
- Parameter descriptions
- Return value description
- A usage example for non-trivial APIs
Preview generated documentation:
swift package generate-documentation --target FixedPointDecimal- SwiftLint is configured in the repo. Follow the existing patterns.
- Don't add comments for self-evident code. Do add comments for non-obvious algorithmic choices.
- Don't add features or abstractions beyond what's needed for the current change.
- Public API additions need DocC documentation (triple-slash comments).
- All arithmetic operations must remain
@inlinablewith zero heap allocations.
This project uses Conventional Commits:
feat: add support for rounding to nearest tick
fix: correct banker's rounding for negative midpoint values
perf: reduce instruction count for multiplication
docs: update comparison table with latest benchmarks
test: add edge cases for Int32 overflow
Breaking changes append !: feat!: rename RoundingMode cases to match FloatingPointRoundingRule
All arithmetic, comparison, and conversion operations are designed for zero heap allocations. Changes that introduce per-call allocations need strong justification and benchmark evidence.
Open an issue for discussion before starting large changes. This saves everyone time.