Module math stdlib

math
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
1
Imported by:
22
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Overview

math provides commonly used mathematical functions for trigonometry, logarithms, etc.

Aliases

This section is empty.

Constants

#constant epsilon

epsilon      = 2.2204460492503130808472633361816E-16

#constant e

e            = 2.71828182845904523536028747135266249775724709369995957496696763

#constant pi

pi           = 3.14159265358979323846264338327950288419716939937510582097494459

#constant pi_2

pi_2         = pi / 2.0

#constant pi_4

pi_4         = pi / 4.0

#constant phi

phi          = 1.61803398874989484820458683436563811772030917980576286213544862

#constant tau

tau          = 6.28318530717958647692528676655900576839433879875021164194988918

#constant one_over_tau

one_over_tau = 1.0 / tau

#constant one_over_pi

one_over_pi  = 1.0 / pi

#constant tau_over2

tau_over2    = tau / 2.0

#constant tau_over4

tau_over4    = tau / 4.0

#constant tau_over8

tau_over8    = tau / 8.0

#constant sqrt2

sqrt2        = 1.41421356237309504880168872420969807856967187537694807317667974

#constant sqrt_3

sqrt_3       = 1.73205080756887729352744634150587236694280525381038062805580697

#constant sqrt_5

sqrt_5       = 2.23606797749978969640917366873127623544061835961152572427089724

#constant sqrt_e

sqrt_e       = 1.64872127070012814684865078781416357165377610071014801157507931

#constant sqrt_pi

sqrt_pi      = 1.77245385090551602729816748334114518279754945612238712821380779

#constant sqrt_tau

sqrt_tau     = 2.50662827463100050241576528481104525300698674060993831662992357

#constant sqrt_phi

sqrt_phi     = 1.27201964951406896425242246173749149171560804184009624861664038

#constant ln2

ln2          = 0.693147180559945309417232121458176568075500134360255254120680009

#constant log2_e

log2_e       = 1.0 / ln2

#constant ln10

ln10         = 2.30258509299404568401799145468436420760110148862877297603332790

#constant log10_e

log10_e      = 1.0 / ln10

#constant two_thirds

two_thirds   = 0.66666666666666666666666666666666666666666666666666666666666667

#constant max_f32

max_f32               = 3.40282346638528859811704183484516925440e+38 // 2**127 * (2**24 - 1) / 2**23

Floating-point limit values max is the largest finite value representable by the type.

smallest_non_zero is the smallest positive, non-zero value representable by the type.

#constant smallest_non_zero_f32

smallest_non_zero_f32 = 1.401298464324817070923729583289916131280e-45 // 1 / 2**(127 - 1 + 23)

Floating-point limit values max is the largest finite value representable by the type.

smallest_non_zero is the smallest positive, non-zero value representable by the type.

#constant max_f64

max_f64               = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52

Floating-point limit values max is the largest finite value representable by the type.

smallest_non_zero is the smallest positive, non-zero value representable by the type.

#constant smallest_non_zero_f64

smallest_non_zero_f64 = 4.940656458412465441765687928682213723651e-324 // 1 / 2**(1023 - 1 + 52)

Floating-point limit values max is the largest finite value representable by the type.

smallest_non_zero is the smallest positive, non-zero value representable by the type.

#constant min_i8

min_i8  = i8(-128)

Integer limit values

#constant max_i8

max_i8  = i8(127)

Integer limit values

#constant min_i16

min_i16 = i16(-32768)

Integer limit values

#constant max_i16

max_i16 = i16(32767)

Integer limit values

#constant min_i32

min_i32 = int(-2147483648)

Integer limit values

#constant max_i32

max_i32 = int(2147483647)

Integer limit values

#constant min_i64

min_i64 = i64(-9223372036854775807 - 1)

Integer limit values

#constant max_i64

max_i64 = i64(9223372036854775807)

Integer limit values

#constant min_u8

min_u8  = u8(0)

Integer limit values

#constant max_u8

max_u8  = u8(255)

Integer limit values

#constant min_u16

min_u16 = u16(0)

Integer limit values

#constant max_u16

max_u16 = u16(65535)

Integer limit values

#constant min_u32

min_u32 = u32(0)

Integer limit values

#constant max_u32

max_u32 = u32(4294967295)

Integer limit values

#constant min_u64

min_u64 = u64(0)

Integer limit values

#constant max_u64

max_u64 = u64(18446744073709551615)

Integer limit values

Sum types

This section is empty.

Functions

#fn abs[T]

inline
fn abs[T](a T) T

abs returns the absolute value of a

#fn abs

JavaScriptinline
fn abs(a f64) f64

Returns the absolute value.

#fn acos

inline
fn acos(x f64) f64

acos returns the arccosine, in radians, of x.

special case is:

acos(x) = nan if x < -1 or x > 1

#fn acos

JavaScriptinline
fn acos(a f64) f64

acos calculates inverse cosine (arccosine).

#fn acosh

fn acosh(x f64) f64

#fn alike

fn alike(a f64, b f64) bool

alike checks if a and b are equal

#fn angle_diff

inline
fn angle_diff(radian_a f64, radian_b f64) f64

angle_diff calculates the difference between angles in radians

#fn aprox_cos

fn aprox_cos(a f64) f64

aprox_cos returns an approximation of sin(a) made using lolremez

#fn aprox_sin

fn aprox_sin(a f64) f64

aprox_sin returns an approximation of sin(a) made using lolremez

#fn asin

fn asin(x_ f64) f64

asin returns the arcsine, in radians, of x.

special cases are:

asin(±0) = ±0 asin(x) = nan if x < -1 or x > 1

#fn asin

JavaScriptinline
fn asin(a f64) f64

asin calculates inverse sine (arcsine).

#fn asinh

fn asinh(x f64) f64

asinh returns the area hyperbolic sine of x

#fn atan

fn atan(x f64) f64

atan returns the arctangent, in radians, of x.

special cases are:

atan(±0) = ±0 atan(±inf) = ±pi/2.0

#fn atan

JavaScriptinline
fn atan(a f64) f64

atan calculates inverse tangent (arctangent).

#fn atan2

fn atan2(y f64, x f64) f64

atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

special cases are (in order):

atan2(y, nan) = nan atan2(nan, x) = nan atan2(+0, x>=0) = +0 atan2(-0, x>=0) = -0 atan2(+0, x<=-0) = +pi atan2(-0, x<=-0) = -pi atan2(y>0, 0) = +pi/2.0 atan2(y<0, 0) = -pi/2.0 atan2(+inf, +inf) = +pi/4 atan2(-inf, +inf) = -pi/4 atan2(+inf, -inf) = 3pi/4 atan2(-inf, -inf) = -3pi/4 atan2(y, +inf) = 0 atan2(y>0, -inf) = +pi atan2(y<0, -inf) = -pi atan2(+inf, x) = +pi/2.0 atan2(-inf, x) = -pi/2.0

#fn atan2

JavaScriptinline
fn atan2(a f64, b f64) f64

atan2 calculates inverse tangent with two arguments, returns the angle between the X axis and the point.

#fn atanh

fn atanh(x f64) f64

atanh returns the area hyperbolic tangent of x

#fn cbrt

fn cbrt(a f64) f64

cbrt returns the cube root of a.

special cases are:

cbrt(±0) = ±0 cbrt(±inf) = ±inf cbrt(nan) = nan

#fn cbrt

JavaScriptinline
fn cbrt(a f64) f64

cbrt calculates cubic root.

#fn ceil

fn ceil(x f64) f64

ceil returns the least integer value greater than or equal to x.

special cases are:

ceil(±0) = ±0 ceil(±inf) = ±inf ceil(nan) = nan

#fn ceil

JavaScriptinline
fn ceil(x f64) f64

ceil returns the nearest f64 greater or equal to the provided value.

#fn clamp

inline
fn clamp(x f64, a f64, b f64) f64

clamp returns x constrained between a and b

#fn close

fn close(a f64, b f64) bool

close checks if a and b are within 1e-14 of each other

#fn copysign

inline
fn copysign(x f64, y f64) f64

copysign returns a value with the magnitude of x and the sign of y

#fn cos

fn cos(x f64) f64

cos calculates the cosine of the angle in radians

#fn cos

JavaScriptinline
fn cos(a f64) f64

cos calculates cosine in radians

#fn cosf

inline
fn cosf(a f32) f32

cosf calculates cosine in radians (float32).

#fn cosf

inline
fn cosf(a f32) f32

cosf calculates cosine in radians (float32)

#fn cosh

fn cosh(x f64) f64

cosh returns the hyperbolic cosine of x in radians

special cases are:

cosh(±0) = 1 cosh(±inf) = +inf cosh(nan) = nan

#fn cosh

JavaScriptinline
fn cosh(a f64) f64

cosh calculates hyperbolic cosine in radians

#fn cot

fn cot(a f64) f64

tan calculates cotangent of a number

#fn count_digits

fn count_digits(number i64) int

count_digits return the number of digits in the number passed.

Number argument accepts any integer type (i8|i16|int|isize|i64) and will be cast to i64

#fn degrees

inline
fn degrees(radians f64) f64

degrees converts from radians to degrees.

#fn digits

fn digits(num i64, params DigitParams) []int

digits returns an array of the digits of num in the given optional base.

The num argument accepts any integer type (i8|i16|int|isize|i64), and will be cast to i64 The base: argument is optional, it will default to base: 10.

This function returns an array of the digits in reverse order i.e.:

Example:

assert math.digits(12345, base: 10) == [5,4,3,2,1]

You can also use it, with an explicit reverse: true parameter, (it will do a reverse of the result array internally => slower):

Example:

assert math.digits(12345, reverse: true) == [1,2,3,4,5]

#fn egcd

fn egcd(a i64, b i64) (i64, i64, i64)

egcd returns (gcd(a, b), x, y) such that |ax + by| = gcd(a, b)

#fn erf

fn erf(a f64) f64

erf returns the error function of x.

special cases are:

erf(+inf) = 1 erf(-inf) = -1 erf(nan) = nan

#fn erfc

fn erfc(a f64) f64

erfc returns the complementary error function of x.

special cases are:

erfc(+inf) = 0 erfc(-inf) = 2 erfc(nan) = nan

#fn exp

fn exp(x f64) f64

exp returns e**x, the base-e exponential of x.

special cases are:

exp(+inf) = +inf exp(nan) = nan Very large values overflow to 0 or +inf.

Very small values underflow to 1.

#fn exp

JavaScriptinline
fn exp(x f64) f64

exp calculates exponent of the number (math.pow(math.E, x)).

#fn exp2

fn exp2(x f64) f64

exp2 returns 2**x, the base-2 exponential of x.

special cases are the same as exp.

#fn expm1

fn expm1(x f64) f64

expm1 calculates e**x - 1 special cases are:

expm1(+inf) = +inf expm1(-inf) = -1 expm1(nan) = nan

#fn f32_bits

fn f32_bits(f f32) u32

f32_bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position.

f32_bits(f32_from_bits(x)) == x.

#fn f32_bits

JavaScript
fn f32_bits(f f32) u32

f32_bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position.

f32_bits(f32_from_bits(x)) == x.

#fn f32_from_bits

fn f32_from_bits(b u32) f32

f32_from_bits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position.

f32_from_bits(f32_bits(x)) == x.

#fn f32_from_bits

JavaScript
fn f32_from_bits(b u32) f32

f32_from_bits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position.

f32_from_bits(f32_bits(x)) == x.

#fn f64_bits

fn f64_bits(f f64) u64

f64_bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and f64_bits(f64_from_bits(x)) == x.

#fn f64_bits

JavaScript
fn f64_bits(f f64) u64

f64_bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and f64_bits(f64_from_bits(x)) == x.

#fn f64_from_bits

fn f64_from_bits(b u64) f64

f64_from_bits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position.

f64_from_bits(f64_bits(x)) == x.

#fn f64_from_bits

JavaScript
fn f64_from_bits(b u64) f64

f64_from_bits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position.

f64_from_bits(f64_bits(x)) == x.

#fn fabs

deprecated:use math.abs() instead
fn fabs(x f64) f64

#fn factorial

fn factorial(n f64) f64

factorial calculates the factorial of the provided value.

#fn factoriali

fn factoriali(n int) i64

factoriali returns 1 for n <= 0 and -1 if the result is too large for a 64 bit integer

#fn floor

fn floor(x f64) f64

floor returns the greatest integer value less than or equal to x.

special cases are:

floor(±0) = ±0 floor(±inf) = ±inf floor(nan) = nan

#fn floor

JavaScriptinline
fn floor(x f64) f64

floor returns the nearest f64 lower or equal of the provided value.

#fn fmod

fn fmod(x f64, y f64) f64

fmod returns the floating-point remainder of number / denom (rounded towards zero)

#fn frexp

fn frexp(x f64) (f64, int)

frexp breaks f into a normalized fraction and an integral power of two.

It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1).

special cases are:

frexp(±0) = ±0, 0 frexp(±inf) = ±inf, 0 frexp(nan) = nan, 0 pub fn frexp(f f64) (f64, int) { mut y := f64_bits(x) ee := int((y >> 52) & 0x7ff) // special cases if ee == 0 { if x != 0.0 { x1p64 := f64_from_bits(0x43f0000000000000) z,e_ := frexp(x * x1p64) return z,e_ - 64 } return x,0 } else if ee == 0x7ff { return x,0 } e_ := ee - 0x3fe y &= 0x800fffffffffffff y |= 0x3fe0000000000000 return f64_from_bits(y),e_

#fn gamma

fn gamma(a f64) f64

gamma returns the gamma function of x.

special ifs are:

gamma(+inf) = +inf gamma(+0) = +inf gamma(-0) = -inf gamma(x) = nan for integer x < 0 gamma(-inf) = nan gamma(nan) = nan

#fn gcd

fn gcd(a_ i64, b_ i64) i64

gcd calculates greatest common (positive) divisor (or zero if a and b are both zero).

#fn get_high_word

fn get_high_word(f f64) u32

get_high_word returns high part of the word of f.

#fn hypot

fn hypot(x f64, y f64) f64

hypot returns the hypotenuse of the triangle give two sides

#fn ilog_b

fn ilog_b(x f64) int

ilog_b returns the binary exponent of x as an integer.

special cases are:

ilog_b(±inf) = max_i32 ilog_b(0) = min_i32 ilog_b(nan) = max_i32

#fn inf

fn inf(sign int) f64

inf returns positive infinity if sign >= 0, negative infinity if sign < 0.

#fn inf

JavaScript
fn inf(sign int) f64

#fn is_finite

fn is_finite(f f64) bool

#fn is_inf

fn is_inf(f f64, sign int) bool

is_inf reports whether f is an infinity, according to sign.

If sign > 0, is_inf reports whether f is positive infinity.

If sign < 0, is_inf reports whether f is negative infinity.

If sign == 0, is_inf reports whether f is either infinity.

#fn is_nan

fn is_nan(f f64) bool

is_nan reports whether f is an IEEE 754 ``not-a-number'' value.

#fn lcm

fn lcm(a i64, b i64) i64

lcm calculates least common (non-negative) multiple.

#fn ldexp

fn ldexp(frac f64, exp int) f64

ldexp calculates frac*(2**exp)

#fn log

fn log(a f64) f64

log returns the logarithm of x

Method :

  1. Argument Reduction: find k and f such that x = 2^k * (1+f), where sqrt(2)/2 < 1+f < sqrt(2) .

  2. Approximation of log(1+f).

    Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) = 2s + 2/3 s3 + 2/5 s5 + ....., = 2s + sR We use a special Remez algorithm on [0,0.1716] to generate a polynomial of degree 14 to approximate R The maximum error of this polynomial approximation is bounded by 2**-58.45. In other words, 2 4 6 8 10 12 14 R(z) ~ Lg1s +Lg2s +Lg3s +Lg4s +Lg5s +Lg6s +Lg7s (the values of Lg1 to Lg7 are listed in the program) and | 2 14 | -58.45 | Lg1s +...+Lg7s - R(z) | <= 2 | | Note that 2s = f - sf = f - hfsq + shfsq, where hfsq = f*f/2.

    In order to guarantee error in log below 1ulp, we compute log by log(1+f) = f - s*(f - R) (if f is not too large) log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)

    1. Finally, log(x) = k*ln2 + log(1+f).

                   = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))         Here ln2 is split into two floating point number:
      
               ln2_hi + ln2_lo,         where n*ln2_hi is always exact for |n| < 2000.
      

Special cases:

 log(x) is NaN with signal if x < 0 (including -inf) ;      log(+inf) is +inf; log(0) is -inf with signal;      log(NaN) is that NaN with no signal.

Accuracy:

 according to an error analysis, the error is always less than      1 ulp (unit in the last place).

#fn log10

fn log10(x f64) f64

log10 returns the decimal logarithm of x.

The special cases are the same as for log.

#fn log1p

fn log1p(x f64) f64

log1p returns log(1+x)

#fn log2

fn log2(x f64) f64

log2 returns the binary logarithm of x.

The special cases are the same as for log.

#fn log_b

fn log_b(x f64) f64

log_b returns the binary exponent of x.

special cases are:

log_b(±inf) = +inf log_b(0) = -inf log_b(nan) = nan

#fn log_factorial

fn log_factorial(n f64) f64

log_factorial calculates the log-factorial of the provided value.

#fn log_gamma

fn log_gamma(x f64) f64

log_gamma returns the natural logarithm and sign (-1 or +1) of Gamma(x).

special ifs are:

log_gamma(+inf) = +inf log_gamma(0) = +inf log_gamma(-integer) = +inf log_gamma(-inf) = -inf log_gamma(nan) = nan

#fn log_gamma_sign

fn log_gamma_sign(a f64) (f64, int)

#fn log_n

fn log_n(x f64, b f64) f64

log_n returns log base b of x

#fn max[T]

inline
fn max[T](a T, b T) T

max returns the maximum of a and b

#fn maxof[T]

inline
fn maxof[T]() T

maxof returns the maximum value of the type T

#fn min[T]

inline
fn min[T](a T, b T) T

min returns the minimum of a and b

#fn minmax

fn minmax(a f64, b f64) (f64, f64)

minmax returns the minimum and maximum value of the two provided.

#fn minof[T]

inline
fn minof[T]() T

minof returns the minimum value of the type T

#fn mod

fn mod(x f64, y f64) f64

Floating-point mod function.

mod returns the floating-point remainder of x/y.

The magnitude of the result is less than y and its sign agrees with that of x.

special cases are:

mod(±inf, y) = nan mod(nan, y) = nan mod(x, 0) = nan mod(x, ±inf) = x mod(x, nan) = nan

#fn modf

fn modf(f f64) (f64, f64)

modf returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f.

special cases are:

modf(±inf) = ±inf, nan modf(nan) = nan, nan

#fn nan

fn nan() f64

nan returns an IEEE 754 ``not-a-number'' value.

#fn nan

JavaScript
fn nan() f64

#fn nextafter

fn nextafter(x f64, y f64) f64

nextafter returns the next representable f64 value after x towards y.

special cases are:

nextafter(x, x) = x nextafter(nan, y) = nan nextafter(x, nan) = nan

#fn nextafter32

fn nextafter32(x f32, y f32) f32

nextafter32 returns the next representable f32 value after x towards y.

special cases are:

nextafter32(x, x) = x nextafter32(nan, y) = nan nextafter32(x, nan) = nan

#fn normalize

fn normalize(x f64) (f64, int)

normalize returns a normal number y and exponent exp satisfying x == y × 2**exp. It assumes x is finite and non-zero.

#fn pow

fn pow(x f64, y f64) f64

pow returns base raised to the provided power.

todo(playXE): make this function work on JS backend, probably problem of JS codegen that it does not work.

#fn pow10

fn pow10(n int) f64

pow10 returns 10**n, the base-10 exponential of n.

special cases are:

pow10(n) = 0 for n < -323 pow10(n) = +inf for n > 308

#fn powf

inline
fn powf(a f32, b f32) f32

powf returns base raised to the provided power. (float32)

#fn powf

inline
fn powf(a f32, b f32) f32

powf returns base raised to the provided power. (float32)

#fn powi

fn powi(a i64, b i64) i64

powi returns base raised to power (a**b) as an integer (i64)

special case:

powi(a, b) = -1 for a = 0 and b < 0

#fn q_rsqrt

inline
fn q_rsqrt(x f64) f64

#fn radians

inline
fn radians(degrees f64) f64

radians converts from degrees to radians.

#fn round

fn round(x f64) f64

round returns the nearest integer, rounding half away from zero.

special cases are:

round(±0) = ±0 round(±inf) = ±inf round(nan) = nan

#fn round

JavaScriptinline
fn round(x f64) f64

round returns the integer nearest to the provided value.

#fn round_sig

fn round_sig(x f64, sig_digits int) f64

Returns the rounded float, with sig_digits of precision.

i.e assert round_sig(4.3239437319748394,6) == 4.323944

#fn round_to_even

fn round_to_even(x f64) f64

round_to_even returns the nearest integer, rounding ties to even.

special cases are:

round_to_even(±0) = ±0 round_to_even(±inf) = ±inf round_to_even(nan) = nan

#fn scalbn

fn scalbn(x f64, n_ int) f64

scalbn scales x by FLT_RADIX raised to the power of n, returning the same as:

scalbn(x,n) = x * FLT_RADIX ** n

#fn sign

inline
fn sign(n f64) f64

sign returns the corresponding sign -1.0, 1.0 of the provided number.

if n is not a number, its sign is nan too.

#fn signbit

inline
fn signbit(x f64) bool

signbit returns a value with the boolean representation of the sign for x

#fn signi

inline
fn signi(n f64) int

signi returns the corresponding sign -1.0, 1.0 of the provided number.

#fn sin

fn sin(x f64) f64

sin calculates the sine of the angle in radians

#fn sin

JavaScriptinline
fn sin(a f64) f64

sin calculates sine in radians

#fn sincos

fn sincos(x f64) (f64, f64)

sincos calculates the sine and cosine of the angle in radians

#fn sinf

inline
fn sinf(a f32) f32

sinf calculates sine in radians (float32)

#fn sinf

inline
fn sinf(a f32) f32

sinf calculates sine in radians (float32)

#fn sinh

fn sinh(x_ f64) f64

sinh calculates hyperbolic sine.

#fn sinh

JavaScriptinline
fn sinh(a f64) f64

sinh calculates hyperbolic sine in radians

#fn sqrt

inline
fn sqrt(a f64) f64

special cases are:

sqrt(+inf) = +inf sqrt(±0) = ±0 sqrt(x < 0) = nan sqrt(nan) = nan

#fn sqrtf

inline
fn sqrtf(a f32) f32

sqrtf calculates square-root of the provided value. (float32)

#fn sqrtf

inline
fn sqrtf(a f32) f32

sqrtf calculates square-root of the provided value. (float32)

#fn sqrti

fn sqrti(a i64) i64

sqrti calculates the integer square-root of the provided value. (i64)

#fn tan

fn tan(a f64) f64

tan calculates tangent of a number

#fn tan

JavaScriptinline
fn tan(a f64) f64

tan calculates tangent.

#fn tanf

inline
fn tanf(a f32) f32

tanf calculates tangent. (float32)

#fn tanf

inline
fn tanf(a f32) f32

tanf calculates tangent. (float32)

#fn tanh

fn tanh(x f64) f64

tanh returns the hyperbolic tangent of x.

special cases are:

tanh(±0) = ±0 tanh(±inf) = ±1 tanh(nan) = nan

#fn tanh

JavaScriptinline
fn tanh(a f64) f64

tanh calculates hyperbolic tangent.

#fn tolerance

fn tolerance(a f64, b f64, tol f64) bool

tolerance checks if a and b difference are less than or equal to the tolerance value

#fn trunc

fn trunc(x f64) f64

trunc returns the integer value of x.

special cases are:

trunc(±0) = ±0 trunc(±inf) = ±inf trunc(nan) = nan

#fn trunc

JavaScriptinline
fn trunc(x f64) f64

trunc rounds a toward zero, returning the nearest integral value that is not larger in magnitude than a.

#fn veryclose

fn veryclose(a f64, b f64) bool

veryclose checks if a and b are within 4e-16 of each other

#fn with_set_high_word

fn with_set_high_word(f f64, hi u32) f64

with_set_high_word sets high word of f to lo

#fn with_set_low_word

fn with_set_low_word(f f64, lo u32) f64

with_set_low_word sets low word of f to lo

Structs

#struct DigitParams

params
pub struct DigitParams {
	base    int = 10
	reverse bool
}

Interfaces

This section is empty.

Enums

This section is empty.