Packages / Mathlib

Mathlib Official

uploaded Apr 23, 2026

Standard Math Library

Mathlib v1.0.0

The Standard Math Library for XCX.

Mathlib provides a comprehensive suite of mathematical functions, constants, and utilities designed for professional XCX development. It covers everything from basic arithmetic to advanced trigonometry and statistics.

Features

  • [1] Constants: High-precision values for PI, E, TAU, PHI, SQRT2, etc.
  • [2] Basic Math: Absolute values, min/max, clamping, and sign functions for both integers and floats.
  • [3] Powers & Roots: Fast exponentiation by squaring (powi, powf), square roots (sqrtf), and cube roots (cbrtf).
  • [4] Logarithms: Natural logs (ln_f), base-2, base-10, and custom base logarithms.
  • [5] Trigonometry: Full set of trig functions (sin, cos, tan), inverse functions (atan, atan2, asin, acos), and hyperbolic variants.
  • [6] Number Theory: GCD, LCM, Primes, Factorials, Fibonacci, and Binomial coefficients.
  • [7] Statistics: Sum, Mean, Variance, Standard Deviation, Median, and Vector operations.
  • [8] Unit Converters: Distance, temperature, and weight conversions.
  • Installation

    Add Mathlib to your project.pax:

    `pax

    deps :: [

    "mathlib@1.0.0"

    ]

    `

    Then run:

    xcx pax install

    Usage

    Include the library in your XCX files:

    `xcx

    include "lib/mathlib/src/math.xcx" as math;

    func main() {

    >! "PI: " + s(math.PI);

    >! "Square root of 16: " + s(math.sqrt_f(16.0));

    >! "Factorial of 5: " + s(math.factorial(5));

    };

    `

    Professional Benchmarking

    Functions like pow_i and factorial are implemented iteratively to avoid recursion depth limits and maximize performance in the XCX VM.


    Published via PAX Package Manager

    Install

    xcx pax add Mathlib@1.0.0
    Download v1.0.0 (tar.gz)

    Downloads

    1

    Stars

    2

    Project Explorer

    project.pax
    readme.md
    src\math.xcx