GizStack
View .mdOpen in ChatGPTOpen in Claude

gizlang/libm

the C math library (libm) in Gizlang, one implementation on every system: a result has the same bits on Linux, macOS and Windows, and a call can inline. gizlang/math re-exports its functions, and the C library of static Linux programs exports them by their C names. The algorithms and their coefficients are those of fdlibm, as musl carries them (fma, scalbn, fmod and hypot are musl's). Arguments of sin, cos and tan beyond 2^20 pi/2 are reduced by the bits of 2/pi (Payne-Hanek). No function sets errno or a floating-point exception flag.

fdlibm: Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved.

gizlang
import * as Libm from "gizlang/libm";

Functions

scalbn

gizlang
function scalbn(x: f64, n: i32): f64

Scale by an integer power of two without constructing an overflowing intermediate power.

Effects: fail.

ldexp

gizlang
function ldexp(x: f64, n: i32): f64

X times 2 to the power N (scalbn).

Effects: fail.

logb

gizlang
function logb(x: f64): f64

The binary exponent of X: -inf for 0, |X| for an infinity, X for a NaN.

Effects: fail.

fabs

gizlang
function fabs(x: f64): f64

The absolute value of X.

Effects: fail.

copysign

gizlang
function copysign(x: f64, y: f64): f64

X with the sign of Y (libm).

Effects: fail.

nextafter

gizlang
function nextafter(x: f64, y: f64): f64

The next double after X toward Y.

Effects: fail.

fmax

gizlang
function fmax(x: f64, y: f64): f64

The larger of X and Y; a NaN loses to a number.

fmin

gizlang
function fmin(x: f64, y: f64): f64

The smaller of X and Y; a NaN loses to a number.

floor

gizlang
function floor(x: f64): f64

The largest integer not greater than X.

Effects: fail.

ceil

gizlang
function ceil(x: f64): f64

The smallest integer not less than X.

Effects: fail.

trunc

gizlang
function trunc(x: f64): f64

X without its fraction (rounded toward zero).

Effects: fail.

rint

gizlang
function rint(x: f64): f64

X rounded to an integer, ties to even.

Effects: fail.

nearbyint

gizlang
function nearbyint(x: f64): f64

X rounded to an integer, ties to even (rint).

Effects: fail.

roundeven

gizlang
function roundeven(x: f64): f64

X rounded to an integer, ties to even (rint).

Effects: fail.

round

gizlang
function round(x: f64): f64

X rounded to an integer, ties away from zero.

Effects: fail.

lround

gizlang
function lround(x: f64): i64

X rounded to an integer, ties away from zero, as an integer.

Effects: fail.

llround

gizlang
function llround(x: f64): i64

X rounded to an integer, ties away from zero, as an integer (lround).

Effects: fail.

lrint

gizlang
function lrint(x: f64): i64

X rounded to an integer, ties to even, as an integer.

Effects: fail.

llrint

gizlang
function llrint(x: f64): i64

X rounded to an integer, ties to even, as an integer (lrint).

Effects: fail.

fmod

gizlang
function fmod(x: f64, y: f64): f64

The remainder of X by Y with the sign of X, exact (musl).

Effects: fail.

remainder

gizlang
function remainder(x: f64, y: f64): f64

X minus the multiple of Y nearest to it, ties to even (fdlibm).

Effects: fail.

fma

gizlang
function fma(x: f64, y: f64, z: f64): f64

X times Y plus Z, rounded once.

Effects: fail.

hypot

gizlang
function hypot(x: f64, y: f64): f64

The length of (X, Y) without overflow or underflow in the squares (musl).

Effects: fail.

cbrt

gizlang
function cbrt(x: f64): f64

The cube root of X (musl).

Effects: fail.

exp

gizlang
function exp(x: f64): f64

e to the power X.

Effects: fail.

expm1

gizlang
function expm1(x: f64): f64

e^x - 1, exact near 0.

Effects: fail.

log

gizlang
function log(x: f64): f64

The natural logarithm of X.

Effects: fail.

log2

gizlang
function log2(x: f64): f64

The base-2 logarithm of X.

Effects: fail.

log10

gizlang
function log10(x: f64): f64

The base-10 logarithm of X.

Effects: fail.

log1p

gizlang
function log1p(x: f64): f64

log(1 + x), exact near 0.

Effects: fail.

pow

gizlang
function pow(x: f64, y: f64): f64

X to the power Y.

Effects: fail.

exp2

gizlang
function exp2(x: f64): f64

2 to the power X.

Effects: fail.

sinh

gizlang
function sinh(x: f64): f64

Hyperbolic sine (libm).

Effects: fail.

cosh

gizlang
function cosh(x: f64): f64

Hyperbolic cosine (libm).

Effects: fail.

tanh

gizlang
function tanh(x: f64): f64

Hyperbolic tangent (libm).

Effects: fail.

asinh

gizlang
function asinh(x: f64): f64

Inverse hyperbolic sine (libm).

Effects: fail.

acosh

gizlang
function acosh(x: f64): f64

Inverse hyperbolic cosine (libm).

Effects: fail.

atanh

gizlang
function atanh(x: f64): f64

Inverse hyperbolic tangent (libm).

Effects: fail.

sin

gizlang
function sin(x: f64): f64

The sine of X (radians).

Effects: fail.

cos

gizlang
function cos(x: f64): f64

The cosine of X (radians).

Effects: fail.

tan

gizlang
function tan(x: f64): f64

The tangent of X (radians).

Effects: fail.

asin

gizlang
function asin(x: f64): f64

The arc sine of X, in radians.

Effects: fail.

acos

gizlang
function acos(x: f64): f64

The arc cosine of X, in radians.

Effects: fail.

atan

gizlang
function atan(x: f64): f64

The arc tangent of X, in radians.

Effects: fail.

atan2

gizlang
function atan2(y: f64, x: f64): f64

The angle of the point (X, Y) from the X axis, in radians (-π to π).

Effects: fail.

erf

gizlang
function erf(x: f64): f64

The error function and its complement, Gamma and log|Gamma| (libm).

Effects: fail.

erfc

gizlang
function erfc(x: f64): f64

The complementary error function, 1 - erf(X).

Effects: fail.

lgamma

gizlang
function lgamma(x0: f64): f64

The natural logarithm of the absolute value of the gamma function of X.

Effects: fail.

tgamma

gizlang
function tgamma(x: f64): f64

The gamma function of X.

Effects: fail.