brick/math
Arbitrary-precision math for PHP. Work with big integers, decimals, and rational numbers via a clean OOP API. Optimized with GMP or BCMath when available, with automatic runtime selection. Requires PHP 8.2+ (older versions available).
Precision-Critical Financial Systems:
0.1 + 0.2 !== 0.3) with exact arithmetic for payment processing or tax engines.Scientific/Engineering Applications:
Build vs. Buy:
Roadmap Acceleration:
float/int in core calculations (e.g., Laravel’s money package or accounting modules).FinancialMathService wrapping BigDecimal for tax logic).Adopt if:
decimal module).Look elsewhere if:
mpmath)."This package solves a hidden technical debt bomb in our system: floating-point inaccuracies. For example, a $100 transaction split 3 ways might render as $33.33333333333333 instead of $33.33 due to PHP’s float limitations. Brick\Math ensures exact calculations—critical for compliance, payments, and scientific tools—while integrating seamlessly with Laravel. It’s a low-risk, high-impact upgrade with MIT licensing and enterprise-grade adoption (used by [list dependents if any])."
*"Brick\Math gives us:
0.1 + 0.2 bugs).bcmath calls).Trade-offs:
BigDecimal vs. native types.Proposal:
BigDecimal/BigInteger with backward-compatible wrappers.Cost: Zero (MIT license). Risk: Low (mature, tested)."*
How can I help you explore Laravel packages today?