# brick/math

Arbitrary-precision arithmetic library for PHP

Repository: https://github.com/brick/math
Canonical: https://ross.abutalabs.com/products/brick-math
Language: PHP
License: MIT
License Family: permissive
Topics: php, arbitrary-precision, biginteger, bigdecimal, bigrational, gmp, bcmath
Last push: 2026-08-25T22:37:18+00:00

## Health v2 (maintenance only)
Score: 98/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 96, longevity 100
- inputs: {"age_days": 4385, "days_push": 8, "days_rel": 25, "gap_med": 7.0, "n_releases_24m": 23}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2162, forks 101 (observed 2026-08-28T04:06:21.033227+00:00)

## What it is
A PHP library for arbitrary-precision arithmetic providing BigInteger, BigDecimal, and BigRational classes. It automatically uses the fastest available calculator implementation (GMP, BCMath, or a pure-PHP fallback).

## Use cases
- do exact math with very large integers in PHP
- handle money calculations without floating-point errors
- work with arbitrary precision decimal numbers
- compute with rational numbers and fractions
- avoid integer overflow in PHP calculations

## When to choose
- you need exact arithmetic beyond PHP's native int/float limits
- you want a well-tested, production-ready precision math library with optional GMP/BCMath acceleration

## When to avoid
- you only need standard floating-point math
- you're on PHP < 8.2 and can't use an older release branch

## Facets
- artifact type: library
- maturity: stable
- function: math
- domain: developer-tools
- platform: php
- tags: arbitrary-precision, biginteger, bigdecimal, bigrational, gmp, bcmath, algorithms

## Member repositories
- brick/math (main) score 98

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:21.033227+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:50:13.876182+00:00, confidence not recorded.
  - readme: https://github.com/brick/math (fetched 2026-08-28T04:06:21.033227+00:00, sha 6a6e9504f9ef)
- Data as of 2026-08-30T08:39:29.467469+00:00.
