math
Generated by tinox doc
Integer math helpers: constants (pi, e, tau), abs/min/max/square/pow/factorial for Int64, and a seeded linear-congruential pseudo-random generator. See mathf for the Float64 equivalents and mathx for number-theory functions (gcd, primes, combinatorics).
Basic helpers
import tinox.core.math;
class Main
{
fnc main() -> Int32
{
println("pi = " + Math::pi().toString());
println("abs(-5) = " + Math::abs(-5).toString());
println("max(3, 7) = " + Math::max(3, 7).toString());
println("2^10 = " + Math::pow(2, 10).toString());
println("5! = " + Math::factorial(5).toString());
return 0;
}
}
class Math
* Math helper class with common mathematical operations * including constants, arithmetic, power functions, and random number generation
Methods
fn pi() → Float64
* Returns the value of pi (3.14159...)
* @return the mathematical constant pi
fn e() → Float64
* Returns Euler's number (2.71828...)
* @return the mathematical constant e
fn tau() → Float64
* Returns tau (2 * pi = 6.28318...)
* @return the mathematical constant tau
fn abs(x: Int64) → Int64
* Returns the absolute value of x
* @param x the input value
* @return the absolute value (always non-negative)
fn min(a: Int64, b: Int64) → Int64
* Returns the smaller of two values
* @param a the first value
* @param b the second value
* @return a if a < b, otherwise b
fn max(a: Int64, b: Int64) → Int64
* Returns the larger of two values
* @param a the first value
* @param b the second value
* @return a if a > b, otherwise b
fn square(x: Int64) → Int64
* Returns x squared (x * x)
* @param x the input value
* @return x multiplied by itself
fn pow(base: Int64, exp: Int64) → Int64
* Returns base raised to the power of exp
* @param base the base value
* @param exp the exponent (must be non-negative)
* @return base raised to the power of exp
fn factorial(n: Int64) → Int64
* Returns the factorial of n (n!)
* Computes n * (n-1) * ... * 2 * 1 recursively.
* For n <= 1, returns 1.
* @param n the input value (must be non-negative)
* @return n factorial
fn randomSeed(seed: Int64) → Int64
* Generates a pseudo-random number from a seed
* Uses a linear congruential generator (LCG) algorithm.
* The same seed always produces the same result.
* @param seed the seed value
* @return a pseudo-random integer