Available

amalgame-math

sqrt / sin / cos / pow / log, constants, IsPrime.

amc package add math GitHub ↗ ← Back to the ecosystem

Overview

Classic math functions over floats: trigonometry, exponential/logarithm, powers, rounding. Constants: π, e, τ, √2, ln 2, ln 10. Integer utilities (GCD, LCM, IsPrime). Thin layer over libm.

Features

  • ✓Trig: Sin, Cos, Tan, Asin, Acos, Atan, Atan2, Sinh, Cosh, Tanh
  • ✓Exponentiation: Exp, Log, Log2, Log10, Pow, Sqrt, Cbrt
  • ✓Constants: Math.PI(), E(), TAU(), SQRT2(), LN2(), LN10(), INF()
  • ✓Integers: AbsI, PowI, MinI, MaxI, ClampI, Gcd, Lcm, IsPrime
  • ✓Rounding and checks: Floor, Ceil, Round, Trunc, IsNaN, IsInf, IsFinite, ApproxEq
  • ✓Minimal wrapper over libm

Example

Minimal usage example — copy-paste runnable after install.

amc package add math

import Amalgame.Math

class Program {
    public static void Main() {
        let h: float = Math.Sqrt(Math.Pow(3.0, 2.0) + Math.Pow(4.0, 2.0))
        Console.WriteLine(String_FromFloat(h))                          // 5
        Console.WriteLine(String_FromInt(Math.Gcd(48, 18)))             // 6
        Console.WriteLine(String_FromFloat(Math.Sin(Math.PI() / 2.0)))  // 1
        if (Math.IsPrime(97)) {
            Console.WriteLine("97 is prime")
        }
    }
}

At a glance

Related packages