abla/math/v8
Generated from source.
Import with import "abla/math/v8".
Source: abla/math/v8/entry.ab
min (fun)
fun min(left: int, right: int): int
Returns the smaller integer.
max (fun)
fun max(left: int, right: int): int
Returns the larger integer.
clamp (fun)
fun clamp(value: int, minimum: int, maximum: int): int
Limits an integer first by the lower bound and then by the upper bound.
ablaF64Sqrt (extern)
noescape extern:"intrinsic" fun ablaF64Sqrt(value: f64): f64
Returns the square root, or NaN for negative input.
ablaF64Floor (extern)
noescape extern:"intrinsic" fun ablaF64Floor(value: f64): f64
Rounds the value toward negative infinity.
ablaF64Ceil (extern)
noescape extern:"intrinsic" fun ablaF64Ceil(value: f64): f64
Rounds the value toward positive infinity.
ablaF64Trunc (extern)
noescape extern:"intrinsic" fun ablaF64Trunc(value: f64): f64
Rounds the value toward zero.
ablaF64Abs (extern)
noescape extern:"intrinsic" fun ablaF64Abs(value: f64): f64
Returns the magnitude, with negative zero mapped to positive zero.
ablaF64RoundEven (extern)
noescape extern:"intrinsic" fun ablaF64RoundEven(value: f64): f64
Returns the nearest integer-valued float, choosing the even integer at a tie.
ablaF64Fma (extern)
noescape extern:"intrinsic" fun ablaF64Fma(x: f64, y: f64, z: f64): f64
Uses the target intrinsic to multiply x and y and add z.
ablaF64FmaIsFused (extern)
noescape extern:"intrinsic" fun ablaF64FmaIsFused(): bool
Returns whether the target intrinsic rounds the multiply-add only once.
mathPi (val)
val mathPi: f64
pi (Math.PI)
mathHalfPi (val)
val mathHalfPi: f64
pi / 2
mathQuarterPi (val)
val mathQuarterPi: f64
pi / 4
mathTau (val)
val mathTau: f64
2 pi
mathE (val)
val mathE: f64
e (Math.E)
mathLn2 (val)
val mathLn2: f64
ln 2 (Math.LN2)
sqrt (fun)
fun sqrt(value: f64): f64
Exact in IEEE-754, and so in JavaScript too. Returns the square root, or NaN for negative input.
floor (fun)
fun floor(value: f64): f64
Rounds the value toward negative infinity.
ceil (fun)
fun ceil(value: f64): f64
Rounds the value toward positive infinity.
trunc (fun)
fun trunc(value: f64): f64
Rounds the value toward zero.
fabs (fun)
fun fabs(value: f64): f64
Returns the magnitude, with negative zero mapped to positive zero.
roundEven (fun)
fun roundEven(value: f64): f64
Round half to even (IEEE roundTiesToEven), e.g. 2.5 -> 2.0, 3.5 -> 4.0.
isNaN (fun)
fun isNaN(value: f64): bool
Returns whether the value is NaN.
isFinite (fun)
fun isFinite(value: f64): bool
Returns whether the value is finite.
fmin (fun)
fun fmin(left: f64, right: f64): f64
Math.min(left, right): NaN if either is NaN, and -0 below +0.
fmax (fun)
fun fmax(left: f64, right: f64): f64
Math.max(left, right): NaN if either is NaN, and +0 above -0.
fclamp (fun)
fun fclamp(value: f64, minimum: f64, maximum: f64): f64
Returns the value limited by comparison with the lower and upper bounds.
lerp (fun)
fun lerp(from: f64, to: f64, t: f64): f64
Returns from + (to - from) * t, extrapolating when t is outside zero through one.
fma (fun)
fun fma(x: f64, y: f64, z: f64): f64
x * y + z rounded once (IEEE 754 fusedMultiplyAdd). JavaScript has no Math.fma: this is abla/math's exact fma, not a port, with the same bits on every target (the hardware's instruction where there is one, an exact software routine elsewhere).
__mathFmaSoftware (fun)
fun __mathFmaSoftware(x: f64, y: f64, z: f64): f64
x y + z rounded once (IEEE 754 fusedMultiplyAdd), in integers: fma where the target has no fused multiply-add instruction, and at compile time. The exact sum is formed in 128 bits with a sticky bit, then rounded once to the nearest double (to even on a tie).
__mathClz (fun)
fun __mathClz(x: int): int
The number of leading zero bits of a 64-bit word.
__mathULess (fun)
@inline
fun __mathULess(a: int, b: int): bool
Compares the two bit patterns as unsigned 64-bit integers.
__mathMulHigh (fun)
@inline
fun __mathMulHigh(a: int, b: int): int
The high 64 bits of the unsigned 128-bit product a * b, from 32-bit halves with the carries out of the low word counted. (LLVM fuses the textbook form, which sums the middle terms first, into a 128-bit multiplication that wasm32 has only as a library call; this form it leaves alone.)
__mathShl128High (fun)
fun __mathShl128High(hi: int, lo: int, n: int): int
The 128-bit (hi, lo) shifted left by n >= 0: the high word, then the low word.
__mathShl128Low (fun)
fun __mathShl128Low(lo: int, n: int): int
Returns the low word after a nonnegative 128-bit left shift.
__mathShr128High (fun)
fun __mathShr128High(hi: int, n: int): int
The 128-bit (hi, lo) shifted right by n >= 0 (logically): high word, low word.
__mathShr128Low (fun)
fun __mathShr128Low(hi: int, lo: int, n: int): int
Returns the low word after a nonnegative 128-bit logical right shift.
hypot (fun)
fun hypot(x: f64, y: f64): f64
Math.hypot(x, y): scaled by the larger magnitude, so it neither overflows nor underflows early; an infinity wins over a NaN.
__v8High (fun)
@inline
fun __v8High(value: f64): int
Returns the sign-extended upper 32 bits of the f64 representation.
__v8Low (fun)
@inline
fun __v8Low(value: f64): int
Returns the lower 32 bits of the f64 representation as a nonnegative int.
__v8Words (fun)
fun __v8Words(high: int, low: int): f64
The f64 whose high and low 32-bit words are these.
__v8ClearLow (fun)
fun __v8ClearLow(value: f64): f64
value with its low 32 bits cleared (SET_LOW_WORD(value, 0)).
__v8Huge (val)
val __v8Huge: f64
1e300 and 1e-300: squared, an overflow to infinity and an underflow to zero.
__v8Tiny (val)
val __v8Tiny: f64
Holds 1e-300, whose square underflows to zero in f64.
__v8Two54 (val)
val __v8Two54: f64
2^54 and 2^-54
__v8TwoM54 (val)
val __v8TwoM54: f64
Holds 2^-54 for rescaling subnormal f64 results.
__v8Scalbn (fun)
fun __v8Scalbn(value: f64, n: int): f64
x · 2^n, rounded once (C's scalbn, as glibc rounds it).
__v8TwoOverPi (val)
val __v8TwoOverPi: array<int>
396 hex digits of 2/pi, 24 bits per entry.
__v8Npio2Hw (val)
val __v8Npio2Hw: array<int>
The high words of n · pi/2 for n = 1 .. 32.
__v8PIo2 (val)
val __v8PIo2: array<f64>
pi/2 in 24-bit pieces.
__v8InvPio2 (val)
val __v8InvPio2: f64
53 bits of 2/pi
__v8Pio2_1 (val)
val __v8Pio2_1: f64
first 33 bits of pi/2
__v8Pio2_1t (val)
val __v8Pio2_1t: f64
pi/2 - __v8Pio2_1
__v8Pio2_2 (val)
val __v8Pio2_2: f64
second 33 bits of pi/2
__v8Pio2_2t (val)
val __v8Pio2_2t: f64
pi/2 - (__v8Pio2_1 + __v8Pio2_2)
__v8Pio2_3 (val)
val __v8Pio2_3: f64
third 33 bits of pi/2
__v8Pio2_3t (val)
val __v8Pio2_3t: f64
pi/2 - (__v8Pio2_1 + __v8Pio2_2 + __v8Pio2_3)
__v8Two24 (val)
val __v8Two24: f64
2^24 and 2^-24
__v8TwoM24 (val)
val __v8TwoM24: f64
Holds 2^-24 for scaling argument-reduction chunks.
__v8RemPio2Large (fun)
fun __v8RemPio2Large(x: f64, var reduced: array<f64>): int
The remainder of a large x (|x| > 2^19 · pi/2, finite) rem pi/2, from __ieee754_rem_pio2: sets reduced[0] + reduced[1] and returns the quadrant count n.
__v8KernelRemPio2 (fun)
fun __v8KernelRemPio2(x: array<f64>, var y: array<f64>, e0: int, nx: int): int
__kernel_rem_pio2 for prec = 2 (53-bit doubles, a two-part result): the remainder of the large x whose 24-bit pieces are x[0 .. nx - 1], scaled by 2^e0, modulo pi/2.
__v8C1 (val)
val __v8C1: f64
cos kernel
__v8C2 (val)
val __v8C2: f64
Holds coefficient 2 of the small-angle cosine polynomial.
__v8C3 (val)
val __v8C3: f64
Holds coefficient 3 of the small-angle cosine polynomial.
__v8C4 (val)
val __v8C4: f64
Holds coefficient 4 of the small-angle cosine polynomial.
__v8C5 (val)
val __v8C5: f64
Holds coefficient 5 of the small-angle cosine polynomial.
__v8C6 (val)
val __v8C6: f64
Holds coefficient 6 of the small-angle cosine polynomial.
__v8S1 (val)
val __v8S1: f64
sin kernel
__v8S2 (val)
val __v8S2: f64
Holds coefficient 2 of the small-angle sine polynomial.
__v8S3 (val)
val __v8S3: f64
Holds coefficient 3 of the small-angle sine polynomial.
__v8S4 (val)
val __v8S4: f64
Holds coefficient 4 of the small-angle sine polynomial.
__v8S5 (val)
val __v8S5: f64
Holds coefficient 5 of the small-angle sine polynomial.
__v8S6 (val)
val __v8S6: f64
Holds coefficient 6 of the small-angle sine polynomial.
__v8KernelCos (fun)
fun __v8KernelCos(x: f64, y: f64): f64
cos(x + y) on [-pi/4, pi/4] (__kernel_cos).
__v8KernelSin (fun)
fun __v8KernelSin(x: f64, y: f64, hasTail: bool): f64
sin(x + y) on [-pi/4, pi/4] (__kernel_sin); y is used when hasTail.
__v8T (val)
val __v8T: array<f64>
tan kernel
__v8Pio4 (val)
val __v8Pio4: f64
pi/4 and its tail
__v8Pio4Lo (val)
val __v8Pio4Lo: f64
Holds the low part of pi / 4 for tangent argument reduction.
__v8KernelTan (fun)
fun __v8KernelTan(value: f64, tail: f64, iy: int): f64
tan(x + y) (iy = 1) or -1 / tan(x + y) (iy = -1) on [-pi/4, pi/4] (__kernel_tan).
__v8TrigReduced (fun)
fun __v8TrigReduced(kind: int, n: int, y0: f64, y1: f64): f64
sin (kind 0), cos (kind 1) or tan (kind 2) of y0 + y1 = x - n · pi/2.
__v8Trig (fun)
fun __v8Trig(x: f64, kind: int): f64
sin (kind 0), cos (kind 1) or tan (kind 2) of x. The argument reduction is __ieee754_rem_pio2's; up to 2^19 · pi/2 it allocates nothing, and beyond that its scratch arrays live in a region.
sin (fun)
fun sin(x: f64): f64
Math.sin(x).
cos (fun)
fun cos(x: f64): f64
Math.cos(x).
tan (fun)
fun tan(x: f64): f64
Math.tan(x).
__v8AtanHi (val)
val __v8AtanHi: array<f64>
atan(0.5), atan(1), atan(1.5) and atan(inf): high and low parts
__v8AtanLo (val)
val __v8AtanLo: array<f64>
Holds the low parts of the arctangents of 0.5, 1, 1.5 and positive infinity.
__v8AT (val)
val __v8AT: array<f64>
atan polynomial
atan (fun)
fun atan(value: f64): f64
Math.atan(x).
__v8PiLo (val)
val __v8PiLo: f64
pi - mathPi
atan2 (fun)
fun atan2(y: f64, x: f64): f64
Math.atan2(y, x): the angle of the vector (x, y) from the +x axis.
__v8ExpOverflow (val)
val __v8ExpOverflow: f64
exp overflows above this (709.782712893384)
__v8ExpUnderflow (val)
val __v8ExpUnderflow: f64
exp underflows below this (-745.1332191019411)
__v8Ln2Hi (val)
val __v8Ln2Hi: f64
ln 2, its high part (low 32 bits zero)
__v8Ln2Lo (val)
val __v8Ln2Lo: f64
ln 2 - __v8Ln2Hi
__v8InvLn2 (val)
val __v8InvLn2: f64
1 / ln 2
__v8P1 (val)
val __v8P1: f64
exp polynomial (also pow's)
__v8P2 (val)
val __v8P2: f64
Holds coefficient 2 of the exponential polynomial.
__v8P3 (val)
val __v8P3: f64
Holds coefficient 3 of the exponential polynomial.
__v8P4 (val)
val __v8P4: f64
Holds coefficient 4 of the exponential polynomial.
__v8P5 (val)
val __v8P5: f64
Holds coefficient 5 of the exponential polynomial.
__v8TwoM1000 (val)
val __v8TwoM1000: f64
2^-1000 and 2^1023
__v8Two1023 (val)
val __v8Two1023: f64
Holds 2^1023 for scaling near the upper end of the f64 range.
exp (fun)
fun exp(value: f64): f64
Math.exp(x).
__v8Lg1 (val)
val __v8Lg1: f64
log polynomial
__v8Lg2 (val)
val __v8Lg2: f64
Holds coefficient 2 of the natural logarithm polynomial.
__v8Lg3 (val)
val __v8Lg3: f64
Holds coefficient 3 of the natural logarithm polynomial.
__v8Lg4 (val)
val __v8Lg4: f64
Holds coefficient 4 of the natural logarithm polynomial.
__v8Lg5 (val)
val __v8Lg5: f64
Holds coefficient 5 of the natural logarithm polynomial.
__v8Lg6 (val)
val __v8Lg6: f64
Holds coefficient 6 of the natural logarithm polynomial.
__v8Lg7 (val)
val __v8Lg7: f64
Holds coefficient 7 of the natural logarithm polynomial.
__v8Third (val)
val __v8Third: f64
1/3 (0.33333333333333333)
log (fun)
fun log(value: f64): f64
Math.log(x): the natural logarithm, -inf at ±0 and NaN below.
__v8DpH (val)
val __v8DpH: f64
log2(1.5), its high part and the rest
__v8DpL (val)
val __v8DpL: f64
Holds the low part of the logarithm base 2 of 1.5 used in the power implementation.
__v8Two53 (val)
val __v8Two53: f64
2^53
__v8L1 (val)
val __v8L1: f64
pow's log polynomial, (3/2)(log(x) - 2s - 2/3 s^3)
__v8L2 (val)
val __v8L2: f64
Holds coefficient 2 of the logarithm inside the power implementation polynomial.
__v8L3 (val)
val __v8L3: f64
Holds coefficient 3 of the logarithm inside the power implementation polynomial.
__v8L4 (val)
val __v8L4: f64
Holds coefficient 4 of the logarithm inside the power implementation polynomial.
__v8L5 (val)
val __v8L5: f64
Holds coefficient 5 of the logarithm inside the power implementation polynomial.
__v8L6 (val)
val __v8L6: f64
Holds coefficient 6 of the logarithm inside the power implementation polynomial.
__v8Lg2H (val)
val __v8Lg2H: f64
ln 2, its high 21 bits and the rest
__v8Lg2L (val)
val __v8Lg2L: f64
Holds the low part of ln 2 used in the power implementation.
__v8Ovt (val)
val __v8Ovt: f64
-(1024 - log2(overflow + 0.5 ulp))
__v8Cp (val)
val __v8Cp: f64
2 / (3 ln 2), as a float, and the rest
__v8CpH (val)
val __v8CpH: f64
Holds the high part of 2 / (3 ln 2) used in the power implementation.
__v8CpL (val)
val __v8CpL: f64
Holds the residual low part of 2 / (3 ln 2) used in the power implementation.
__v8IvLn2H (val)
val __v8IvLn2H: f64
1 / ln 2, its high 24 bits and the rest
__v8IvLn2L (val)
val __v8IvLn2L: f64
Holds the low part of 1 / ln 2 used in the power implementation.
pow (fun)
fun pow(x: f64, y: f64): f64
Math.pow(x, y), as JavaScript defines it: pow(x, ±0) is 1 for every x, a NaN anywhere else gives NaN, and so does pow(±1, ±inf).
__mathF32 (fun)
fun __mathF32(value: f32): f64
Widens an f32 value to f64.
__mathToF32 (fun)
fun __mathToF32(value: f64): f32
Narrows an f64 value to f32 with floating-point rounding.
sqrt (fun)
fun sqrt(value: f32): f32
Returns the square root, or NaN for negative input.
floor (fun)
fun floor(value: f32): f32
Rounds the value toward negative infinity.
ceil (fun)
fun ceil(value: f32): f32
Rounds the value toward positive infinity.
trunc (fun)
fun trunc(value: f32): f32
Rounds the value toward zero.
fabs (fun)
fun fabs(value: f32): f32
Returns the magnitude, with negative zero mapped to positive zero.
roundEven (fun)
fun roundEven(value: f32): f32
Returns the nearest integer-valued float, choosing the even integer at a tie.
isNaN (fun)
fun isNaN(value: f32): bool
Returns whether the value is NaN.
isFinite (fun)
fun isFinite(value: f32): bool
Returns whether the value is finite.
fmin (fun)
fun fmin(left: f32, right: f32): f32
Returns the smaller float, with negative zero ordered first and NaN propagated.
fmax (fun)
fun fmax(left: f32, right: f32): f32
Returns the larger float, with positive zero ordered last and NaN propagated.
fclamp (fun)
fun fclamp(value: f32, minimum: f32, maximum: f32): f32
Returns the value limited by comparison with the lower and upper bounds.
fma (fun)
fun fma(x: f32, y: f32, z: f32): f32
Returns the fused multiply-add computed in f64 and narrowed to f32.
lerp (fun)
fun lerp(from: f32, to: f32, t: f32): f32
Returns from + (to - from) * t, extrapolating when t is outside zero through one.
atan2 (fun)
fun atan2(y: f32, x: f32): f32
Returns the angle of (x, y) from the positive x axis in radians, or NaN if either coordinate is NaN.
hypot (fun)
fun hypot(x: f32, y: f32): f32
Returns the Euclidean length of (x, y), with infinity taking precedence over NaN.
exp (fun)
fun exp(value: f32): f32
Returns e raised to the input, with overflow to positive infinity and underflow to zero.
log (fun)
fun log(value: f32): f32
Returns the natural logarithm, negative infinity at zero, or NaN for negative input.
atan (fun)
fun atan(value: f32): f32
Returns the arctangent in radians, or NaN for NaN.
sin (fun)
fun sin(value: f32): f32
Returns the sine of an angle in radians, or NaN for infinite or NaN input.
cos (fun)
fun cos(value: f32): f32
Returns the cosine of an angle in radians, or NaN for infinite or NaN input.
tan (fun)
fun tan(value: f32): f32
Returns the tangent of an angle in radians, or NaN for infinite or NaN input.
pow (fun)
fun pow(x: f32, y: f32): f32
Raises the base to the exponent with JavaScript's exceptional cases, including one for a zero exponent.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.