Packages / Mathlib

Mathlib Official

uploaded Jul 17, 2026

Standard math library for XCX — constants, arithmetic, trigonometry, statistics, geometry, combinatorics, unit conversion, and bit operations

mathlib

Standard math library for XCX. Provides constants, arithmetic, trigonometry, statistics, geometry, combinatorics, unit conversion, and bit operations — all implemented in pure XCX with no external dependencies.

Installation

sh

xcx pax add mathlib@latest

Usage

xcx

include "mathlib/math.xcx" as math;

f: area = math.circle_area(5.0);

f: root = math.sqrt_f(144.0);

f: angle = math.sin_f(math.PI / 4.0);

Contents

| Module | Functions |

|---|---|

| Constants | PI, E, TAU, PHI, SQRT2, LN2, INF, EPSILON, INTMAX, INTMIN |

| Integer math | absi, mini, maxi, clampi, signi, wrapi, same_sign |

| Float math | absf, minf, maxf, clampf, floorf, ceilf, roundf, roundto, lerp, lerpclamped, smoothstep, remap, nearlyequal |

| Powers & roots | powi, powf, sqrtf, cbrtf, nroot_f, hypot, hypot3 |

| Logarithms & exp | expf, lnf, log2f, log10f, log_base |

| Trigonometry | sinf, cosf, tanf, asinf, acosf, atanf, atan2f, degtorad, radto_deg |

| Number theory | gcd, lcm, is_prime, factorial, fibonacci |

| Statistics | sum, mean, variance, stddev, median, minarr, maxarr, rangearr, weightedmean, dotproduct, norm_vec, correlation |

| Unit conversion | length, weight, temperature, volume, speed, data |

| Geometry | circlearea, rectarea, trianglearea, triangleareaheron, spherevolume, dist2d, dist3d |

| Combinatorics | combinations, permutations, factorial, catalan, derangements, surjections |

| Bit operations | is_pow2, popcount |

Install

xcx pax add Mathlib@4.2.0
Download v4.2.0 (tar.gz)

Downloads

33

Stars

2

Project Explorer

README.md
project.pax
src
math.xcx