Module: math.floats
Source: ./math/floats.reef
Overview
math/floats - Extended floating-point mathematical functions
Provides additional floating-point operations including:
- Mathematical constants (pi, e)
- Inverse trigonometric functions
- Additional utility functions
- Special value checking (NaN, infinity)
Note: Basic float functions (sqrt, sin, cos, etc.) are in math/basic
Functions
fn pi(): float
Returns the mathematical constant pi (3.14159...)
fn e(): float
Returns Euler's number e (2.71828...)
fn tau(): float
Returns tau (2 * pi = 6.28318...)
fn trunc_f(x: float): float
Returns x truncated toward zero (removes fractional part)
fn cbrt_f(x: float): float
Returns the cube root of x
fn log2_f(x: float): float
Returns the base-2 logarithm of x
fn asin_f(x: float): float
Returns the arc sine of x (result in radians) Input must be in range [-1, 1]
fn acos_f(x: float): float
Returns the arc cosine of x (result in radians) Input must be in range [-1, 1]
fn atan_f(x: float): float
Returns the arc tangent of x (result in radians)
fn atan2_f(y: float, x: float): float
Returns the arc tangent of y/x using signs to determine quadrant Result in radians, range [-pi, pi]
fn sinh_f(x: float): float
Returns the hyperbolic sine of x
fn cosh_f(x: float): float
Returns the hyperbolic cosine of x
fn tanh_f(x: float): float
Returns the hyperbolic tangent of x
fn hypot_f(x: float, y: float): float
Returns the hypotenuse: sqrt(xx + yy) More accurate than computing directly for large values
fn degrees(rad: float): float
Converts radians to degrees
fn radians(deg: float): float
Converts degrees to radians
fn clamp_f(x: float, lo: float, hi: float): float
Clamps x to the range [lo, hi]
fn sign_f(x: float): int
Returns -1 if x < 0, 0 if x == 0, 1 if x > 0
fn lerp_f(a: float, b: float, t: float): float
Linear interpolation between a and b Returns a when t=0, b when t=1
fn is_nan(x: float): bool
Returns true if x is NaN (Not a Number)
fn is_infinite(x: float): bool
Returns true if x is positive or negative infinity
fn is_finite(x: float): bool
Returns true if x is a normal finite number (not NaN or infinity)
fn to_int(x: float): int
Converts float to int by truncating toward zero
fn to_int_floor(x: float): int
Converts float to int by rounding toward negative infinity
fn to_int_ceil(x: float): int
Converts float to int by rounding toward positive infinity
fn to_int_round(x: float): int
Converts float to int by rounding to nearest integer
Generated by reefc doc