math
The math module provides implementations of common math functionality and support for dealing with floating point numbers.
Submodules
Index
Types
type fexcept = enum uint {
NONE = 0, INVALID = 1 << 0,
__DENORM = 1 << 1, DIVBYZERO = 1 << 2, OVERFLOW = 1 << 3,
UNDERFLOW = 1 << 4,
INEXACT = 1 << 5,
ALL = INVALID | __DENORM | DIVBYZERO | OVERFLOW | UNDERFLOW | INEXACT, };
type floatinfo = struct {
mantbits: u64,
expbits: u64,
expbias: int,
mantmask: u64,
expmask: u64,
};
type fround = enum uint {
TONEAREST = 0, DOWNWARD = 1024, UPWARD = 2048, TOWARDZERO = 3072, };
Constants
def E: f64 = 2.718281828459045;
def F32_EPS: f32 = 1.1920928955078125e-7;
def F32_EXPONENT_BIAS: u16 = 127;
def F32_EXPONENT_BITS: u64 = 8;
def F32_EXPONENT_MASK: u64 = (1 << F32_EXPONENT_BITS) - 1;
def F32_MANTISSA_BITS: u64 = 23;
def F32_MANTISSA_MASK: u64 = (1 << F32_MANTISSA_BITS) - 1;
def F32_MAX_NORMAL: f32 = 3.4028234e38;
def F32_MIN: f32 = 1.0e-45;
def F32_MIN_NORMAL: f32 = 1.1754944e-38;
def F64_EPS: f64 = 2.2204e-16;
def F64_EXPONENT_BIAS: u16 = 1023;
def F64_EXPONENT_BITS: u64 = 11;
def F64_EXPONENT_MASK: u64 = (1 << F64_EXPONENT_BITS) - 1;
def F64_MANTISSA_BITS: u64 = 52;
def F64_MANTISSA_MASK: u64 = (1 << F64_MANTISSA_BITS) - 1;
def F64_MAX_NORMAL: f64 = 1.7976931348623157e308;
def F64_MIN: f64 = 5.0e-324;
def F64_MIN_NORMAL: f64 = 2.2250738585072014e-308;
def INF: f32 = 1.0 / 0.0;
def LN2_HI: f64 = 0.6931471803691238;
def LN2_LO: f64 = 1.9082149292705877e-10;
def LN_10: f64 = 2.302585092994046;
def LN_2: f64 = 0.6931471805599453;
def LOG10_E: f64 = 1f64 / LN_10;
def LOG2_E: f64 = 1f64 / LN_2;
def NAN: f32 = 0.0 / 0.0;
def PHI: f64 = 1.618033988749895;
def PI: f64 = 3.141592653589793;
def SQRT_2: f64 = 1.4142135623730951;
def SQRT_E: f64 = 1.6487212707001282;
def SQRT_PHI: f64 = 1.272019649514069;
def SQRT_PI: f64 = 1.772453850905516;
def STANDARD_TOL: f64 = 1.0e-14;
def TAU: f64 = 6.283185307179586;
Globals
const f32info: floatinfo;
const f64info: floatinfo;
Functions
fn absf(n: types::floating) f64;
fn absf32(n: f32) f32;
fn absf64(n: f64) f64;
fn absi(n: types::signed) u64;
fn absi16(n: i16) u16;
fn absi32(n: i32) u32;
fn absi64(n: i64) u64;
fn absi8(n: i8) u8;
fn acosf64(x: f64) f64;
fn acoshf64(x: f64) f64;
fn addu(x: uint, y: uint, carry: uint) (uint, uint);
fn addu32(x: u32, y: u32, carry: u32) (u32, u32);
fn addu64(x: u64, y: u64, carry: u64) (u64, u64);
fn asinf64(x: f64) f64;
fn asinhf64(x: f64) f64;
fn atan2f64(y: f64, x: f64) f64;
fn atanf64(x: f64) f64;
fn atanhf64(x: f64) f64;
fn bit_size_u(x: uint) u8;
fn bit_size_u16(x: u16) u8;
fn bit_size_u32(x: u32) u8;
fn bit_size_u64(x: u64) u8;
fn bit_size_u8(x: u8) u8;
fn ceilf64(x: f64) f64;
fn clearexcept(ex: fexcept) void;
fn copysign(x: types::floating, y: types::floating) f64;
fn copysignf32(x: f32, y: f32) f32;
fn copysignf64(x: f64, y: f64) f64;
fn cosf64(x: f64) f64;
fn coshf64(x: f64) f64;
fn divu(hi: uint, lo: uint, y: uint) (uint, uint);
fn divu32(hi: u32, lo: u32, y: u32) (u32, u32);
fn divu64(hi: u64, lo: u64, y: u64) (u64, u64);
fn eqwithin(x: types::floating, y: types::floating, tol: types::floating) bool;
fn eqwithinf32(x: f32, y: f32, tol: f32) bool;
fn eqwithinf64(x: f64, y: f64, tol: f64) bool;
fn exp2f64(x: f64) f64;
fn expf64(x: f64) f64;
fn expmultif64(hi: f64, lo: f64, k: i64) f64;
fn f32bits(n: f32) u32;
fn f32frombits(n: u32) f32;
fn f64bits(n: f64) u64;
fn f64frombits(n: u64) f64;
fn floorf64(x: f64) f64;
fn frexp(n: types::floating) (f64, i64);
fn frexpf32(n: f32) (f32, i64);
fn frexpf64(n: f64) (f64, i64);
fn gcd(a: u64, b: u64) u64;
fn getround() fround;
fn hypotf64(a: f64, b: f64) f64;
fn isclose(x: types::floating, y: types::floating) bool;
fn isclosef32(x: f32, y: f32) bool;
fn isclosef64(x: f64, y: f64) bool;
fn isinf(n: f64) bool;
fn isnan(n: f64) bool;
fn isnegative(x: types::floating) bool;
fn isnegativef32(x: f32) bool;
fn isnegativef64(x: f64) bool;
fn isnormal(n: types::floating) bool;
fn isnormalf32(n: f32) bool;
fn isnormalf64(n: f64) bool;
fn ispositive(x: types::floating) bool;
fn ispositivef32(x: f32) bool;
fn ispositivef64(x: f64) bool;
fn issubnormal(n: types::floating) bool;
fn issubnormalf32(n: f32) bool;
fn issubnormalf64(n: f64) bool;
fn ldexpf32(mantissa: f32, exp: i64) f32;
fn ldexpf64(mantissa: f64, exp: i64) f64;
fn leading_zeros_u(x: uint) u8;
fn leading_zeros_u16(x: u16) u8;
fn leading_zeros_u32(x: u32) u8;
fn leading_zeros_u64(x: u64) u8;
fn leading_zeros_u8(x: u8) u8;
fn log10f64(x: f64) f64;
fn log1pf64(x: f64) f64;
fn log2f64(x: f64) f64;
fn logf64(x: f64) f64;
fn modf64(x: f64, y: f64) f64;
fn modfracf32(n: f32) (f32, f32);
fn modfracf64(n: f64) (f64, f64);
fn mulu(x: uint, y: uint) (uint, uint);
fn mulu32(x: u32, y: u32) (u32, u32);
fn mulu64(x: u64, y: u64) (u64, u64);
fn nextafterf32(x: f32, y: f32) f32;
fn nextafterf64(x: f64, y: f64) f64;
fn normalizef32(n: f32) (f32, i64);
fn normalizef64(n: f64) (f64, i64);
fn popcount(x: u64) u8;
fn powf64(x: f64, p: f64) f64;
fn raiseexcept(ex: fexcept) void;
fn remu(hi: uint, lo: uint, y: uint) uint;
fn remu32(hi: u32, lo: u32, y: u32) u32;
fn remu64(hi: u64, lo: u64, y: u64) u64;
fn roundf64(x: f64) f64;
fn setround(mode: fround) void;
fn signf(x: types::floating) i64;
fn signf32(x: f32) i64;
fn signf64(x: f64) i64;
fn signi(n: types::signed) i64;
fn signi16(n: i16) i16;
fn signi32(n: i32) i32;
fn signi64(n: i64) i64;
fn signi8(n: i8) i8;
fn sinf64(x: f64) f64;
fn sinhf64(x: f64) f64;
fn sqrtf64(x: f64) f64;
fn subu(x: uint, y: uint, carry: uint) (uint, uint);
fn subu32(x: u32, y: u32, borrow: u32) (u32, u32);
fn subu64(x: u64, y: u64, borrow: u64) (u64, u64);
fn tanf64(x: f64) f64;
fn tanhf64(x: f64) f64;
fn testexcept(ex: fexcept) fexcept;
fn trailing_zeros_u(x: uint) u8;
fn trailing_zeros_u16(x: u16) u8;
fn trailing_zeros_u32(x: u32) u8;
fn trailing_zeros_u64(x: u64) u8;
fn trailing_zeros_u8(x: u8) u8;
fn truncf64(x: f64) f64;
Types
type fexcept
type fexcept = enum uint {
NONE = 0, INVALID = 1 << 0,
__DENORM = 1 << 1, DIVBYZERO = 1 << 2, OVERFLOW = 1 << 3,
UNDERFLOW = 1 << 4,
INEXACT = 1 << 5,
ALL = INVALID | __DENORM | DIVBYZERO | OVERFLOW | UNDERFLOW | INEXACT, };
Defines flags characterizing types of floating point exceptions, Each of the flags is only defined when the target platform supports handling the corresponding exception. Flags NONE and ALL are always defined and correspond to a bitwise OR of none and all defined flags respectively. Platforms may define additional nonstandard flags.
Examples:
math::raiseexcept(math::fexcept::UNDERFLOW); // raise UNDERFLOW
math::clearexcept(math::fexcept::ALL); // clear all exceptions
// e will be math::fexcept::INVALID
math::clearexcept(math::fexcept::ALL);
let a = 0.0/0.0;
let e = math::testexcept(math::fexcept::INVALID | math::fexcept::INEXACT);
type floatinfo
type floatinfo = struct {
mantbits: u64,
expbits: u64,
expbias: int,
mantmask: u64,
expmask: u64,
};
Contains information about the structure of a specific floating point number type.
type fround
type fround = enum uint {
TONEAREST = 0, DOWNWARD = 1024, UPWARD = 2048, TOWARDZERO = 3072, };
Defines values characterizing different floating point rounding behaviors. Each of the values is only definined when the target platform supports the corresponding rounding mode.
Constants
def E
def E: f64 = 2.718281828459045;
e - https://oeis.org/A001113
def F32_EPS
def F32_EPS: f32 = 1.1920928955078125e-7;
The difference between 1 and the smallest f32 representable value that is greater than 1.
def F32_EXPONENT_BIAS
def F32_EXPONENT_BIAS: u16 = 127;
The bias of the exponent of the binary representation of f32. Subtract this from the exponent in the binary representation to get the actual exponent.
def F32_EXPONENT_BITS
def F32_EXPONENT_BITS: u64 = 8;
The number of bits in the exponent of the binary representation of f32.
def F32_EXPONENT_MASK
def F32_EXPONENT_MASK: u64 = (1 << F32_EXPONENT_BITS) - 1;
Mask with each bit of an f32's exponent set.
def F32_MANTISSA_BITS
def F32_MANTISSA_BITS: u64 = 23;
The number of bits in the significand of the binary representation of f32.
def F32_MANTISSA_MASK
def F32_MANTISSA_MASK: u64 = (1 << F32_MANTISSA_BITS) - 1;
Mask with each bit of an f32's mantissa set.
def F32_MAX_NORMAL
def F32_MAX_NORMAL: f32 = 3.4028234e38;
The largest representable f32 value which is less than Infinity.
def F32_MIN
def F32_MIN: f32 = 1.0e-45;
The smallest (subnormal) f32 value greater than zero.
def F32_MIN_NORMAL
def F32_MIN_NORMAL: f32 = 1.1754944e-38;
The smallest representable normal f32 value.
def F64_EPS
def F64_EPS: f64 = 2.2204e-16;
The difference between 1 and the smallest f64 representable value that is greater than 1.
def F64_EXPONENT_BIAS
def F64_EXPONENT_BIAS: u16 = 1023;
The bias of the exponent of the binary representation of f64. Subtract this from the exponent in the binary representation to get the actual exponent.
def F64_EXPONENT_BITS
def F64_EXPONENT_BITS: u64 = 11;
The number of bits in the exponent of the binary representation of f64.
def F64_EXPONENT_MASK
def F64_EXPONENT_MASK: u64 = (1 << F64_EXPONENT_BITS) - 1;
Mask with each bit of an f64's exponent set.
def F64_MANTISSA_BITS
def F64_MANTISSA_BITS: u64 = 52;
The number of bits in the significand of the binary representation of f64.
def F64_MANTISSA_MASK
def F64_MANTISSA_MASK: u64 = (1 << F64_MANTISSA_BITS) - 1;
Mask with each bit of an f64's mantissa set.
def F64_MAX_NORMAL
def F64_MAX_NORMAL: f64 = 1.7976931348623157e308;
The largest representable f64 value which is less than Infinity.
def F64_MIN
def F64_MIN: f64 = 5.0e-324;
The smallest (subnormal) f64 value greater than zero.
def F64_MIN_NORMAL
def F64_MIN_NORMAL: f64 = 2.2250738585072014e-308;
The smallest representable normal f64 value.
def INF
def INF: f32 = 1.0 / 0.0;
The floating point value representing positive infinity. Use -INF for negative infinity.
def LN2_HI
def LN2_HI: f64 = 0.6931471803691238;
ln(2) - https://oeis.org/A002162
def LN2_LO
def LN2_LO: f64 = 1.9082149292705877e-10;
ln(2) - https://oeis.org/A002162
def LN_10
def LN_10: f64 = 2.302585092994046;
ln(10) - https://oeis.org/A002392
def LN_2
def LN_2: f64 = 0.6931471805599453;
ln(2) - https://oeis.org/A002162
def LOG10_E
def LOG10_E: f64 = 1f64 / LN_10;
log_{10}(e)
def LOG2_E
def LOG2_E: f64 = 1f64 / LN_2;
log_{2}(e)
def NAN
def NAN: f32 = 0.0 / 0.0;
The floating point value representing Not a Number, i.e. an undefined or unrepresentable value. You cannot test if a number is NaN by comparing to this value; see isnan instead.
def PHI
def PHI: f64 = 1.618033988749895;
phi - https://oeis.org/A001622
def PI
def PI: f64 = 3.141592653589793;
pi - https://oeis.org/A000796
def SQRT_2
def SQRT_2: f64 = 1.4142135623730951;
sqrt(2) - https://oeis.org/A002193
def SQRT_E
def SQRT_E: f64 = 1.6487212707001282;
sqrt(e) - https://oeis.org/A019774
def SQRT_PHI
def SQRT_PHI: f64 = 1.272019649514069;
sqrt(phi) - https://oeis.org/A139339
def SQRT_PI
def SQRT_PI: f64 = 1.772453850905516;
sqrt(pi) - https://oeis.org/A002161
def STANDARD_TOL
def STANDARD_TOL: f64 = 1.0e-14;
The standard tolerance used by isclose(), which is just an arbitrary way to measure whether two floating-point numbers are "sufficiently" close to each other.
def TAU
def TAU: f64 = 6.283185307179586;
tau - https://oeis.org/A019692
Globals
let f32info
const f32info: floatinfo;
A floatinfo structure defining the structure of the f32 type.
let f64info
const f64info: floatinfo;
A floatinfo structure defining the structure of the f64 type.
Functions
fn absf
fn absf(n: types::floating) f64;
Returns the absolute value of floating-point number n.
fn absf32
fn absf32(n: f32) f32;
Returns the absolute value of f32 n.
fn absf64
fn absf64(n: f64) f64;
Returns the absolute value of f64 n.
fn absi
fn absi(n: types::signed) u64;
Returns the absolute value of signed integer n.
fn absi16
fn absi16(n: i16) u16;
Returns the absolute value of signed integer n.
fn absi32
fn absi32(n: i32) u32;
Returns the absolute value of signed integer n.
fn absi64
fn absi64(n: i64) u64;
Returns the absolute value of signed integer n.
fn absi8
fn absi8(n: i8) u8;
Returns the absolute value of signed integer n.
fn acosf64
fn acosf64(x: f64) f64;
Returns the arccosine, in radians, of x.
fn acoshf64
fn acoshf64(x: f64) f64;
Returns the inverse hyperbolic cosine of x.
fn addu
fn addu(x: uint, y: uint, carry: uint) (uint, uint);
Calls either addu32() or addu64() depending on size(uint).
fn addu32
fn addu32(x: u32, y: u32, carry: u32) (u32, u32);
Returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1, otherwise the behavior is undefined. The carry_out output is guaranteed to be 0 or 1.
fn addu64
fn addu64(x: u64, y: u64, carry: u64) (u64, u64);
Returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1, otherwise the behavior is undefined. The carry_out output is guaranteed to be 0 or 1.
fn asinf64
fn asinf64(x: f64) f64;
Returns the arcsine, in radians, of x.
fn asinhf64
fn asinhf64(x: f64) f64;
Returns the inverse hyperbolic sine of x.
fn atan2f64
fn atan2f64(y: f64, x: f64) f64;
Returns the arctangent, in radians, of y / x.
fn atanf64
fn atanf64(x: f64) f64;
Returns the arctangent, in radians, of x.
fn atanhf64
fn atanhf64(x: f64) f64;
Returns the inverse hyperbolic tangent of x.
fn bit_size_u
fn bit_size_u(x: uint) u8;
Returns the minimum number of bits required to represent x.
fn bit_size_u16
fn bit_size_u16(x: u16) u8;
Returns the minimum number of bits required to represent x.
fn bit_size_u32
fn bit_size_u32(x: u32) u8;
Returns the minimum number of bits required to represent x.
fn bit_size_u64
fn bit_size_u64(x: u64) u8;
Returns the minimum number of bits required to represent x.
fn bit_size_u8
fn bit_size_u8(x: u8) u8;
Returns the minimum number of bits required to represent x.
fn ceilf64
fn ceilf64(x: f64) f64;
Returns the least integer value greater than or equal to x.
fn clearexcept
fn clearexcept(ex: fexcept) void;
Accepts a set of flags from fexcept ORed together and clears exceptions corresponding to the given flags.
fn copysign
fn copysign(x: types::floating, y: types::floating) f64;
Returns x, but with the sign of y.
fn copysignf32
fn copysignf32(x: f32, y: f32) f32;
Returns x, but with the sign of y.
fn copysignf64
fn copysignf64(x: f64, y: f64) f64;
Returns x, but with the sign of y.
fn cosf64
fn cosf64(x: f64) f64;
Returns the cosine of x, in radians.
fn coshf64
fn coshf64(x: f64) f64;
Returns the hyperbolic cosine of x.
fn divu
fn divu(hi: uint, lo: uint, y: uint) (uint, uint);
Calls either divu32() or divu64() depending on size(uint).
fn divu32
fn divu32(hi: u32, lo: u32, y: u32) (u32, u32);
Returns the quotient and remainder of (hi, lo) divided by y: quo = (hi, lo) / y, rem = (hi, lo) % y with the dividend bits' upper half in parameter hi and the lower half in parameter lo. Panics for y == 0 (division by zero) or y <= hi (quotient overflow).
fn divu64
fn divu64(hi: u64, lo: u64, y: u64) (u64, u64);
Returns the quotient and remainder of (hi, lo) divided by y: quo = (hi, lo) / y, rem = (hi, lo) % y with the dividend bits' upper half in parameter hi and the lower half in parameter lo. Panics for y == 0 (division by zero) or y <= hi (quotient overflow).
fn eqwithin
fn eqwithin(x: types::floating, y: types::floating, tol: types::floating) bool;
Returns whether x and y are within tol of each other.
fn eqwithinf32
fn eqwithinf32(x: f32, y: f32, tol: f32) bool;
Returns whether x and y are within tol of each other.
fn eqwithinf64
fn eqwithinf64(x: f64, y: f64, tol: f64) bool;
Returns whether x and y are within tol of each other.
fn exp2f64
fn exp2f64(x: f64) f64;
Returns 2^x.
fn expf64
fn expf64(x: f64) f64;
Returns e^x.
fn expmultif64
fn expmultif64(hi: f64, lo: f64, k: i64) f64;
Returns e^r * 2^k where r = hi - lo and |r| <= (ln(2) / 2).
fn f32bits
fn f32bits(n: f32) u32;
Returns the binary representation of the given f32.
fn f32frombits
fn f32frombits(n: u32) f32;
Returns f32 with the given binary representation.
fn f64bits
fn f64bits(n: f64) u64;
Returns the binary representation of the given f64.
fn f64frombits
fn f64frombits(n: u64) f64;
Returns f64 with the given binary representation.
fn floorf64
fn floorf64(x: f64) f64;
Returns the greatest integer value less than or equal to x.
fn frexp
fn frexp(n: types::floating) (f64, i64);
Breaks a float down into its mantissa and exponent. The mantissa will be between 0.5 and 1.
fn frexpf32
fn frexpf32(n: f32) (f32, i64);
Breaks a f32 down into its mantissa and exponent. The mantissa will be between 0.5 and 1.
fn frexpf64
fn frexpf64(n: f64) (f64, i64);
Breaks a f64 down into its mantissa and exponent. The mantissa will be between 0.5 and 1.
fn gcd
fn gcd(a: u64, b: u64) u64;
Returns the greatest common divisor of a and b.
fn getround
fn getround() fround;
Returns the value corresponding to the current rounding mode
fn hypotf64
fn hypotf64(a: f64, b: f64) f64;
Returns the square root of a*a + b*b, taking care to avoid unnecessary overflow and underflow.
fn isclose
fn isclose(x: types::floating, y: types::floating) bool;
Returns whether x and y are within STANDARD_TOL of each other.
fn isclosef32
fn isclosef32(x: f32, y: f32) bool;
Returns whether x and y are within STANDARD_TOL of each other.
fn isclosef64
fn isclosef64(x: f64, y: f64) bool;
Returns whether x and y are within STANDARD_TOL of each other.
fn isinf
fn isinf(n: f64) bool;
Returns true if the given floating-point number is infinite.
fn isnan
fn isnan(n: f64) bool;
Returns true if the given floating-point number is NaN.
fn isnegative
fn isnegative(x: types::floating) bool;
Returns whether or not x is negative.
fn isnegativef32
fn isnegativef32(x: f32) bool;
Returns whether or not x is negative.
fn isnegativef64
fn isnegativef64(x: f64) bool;
Returns whether or not x is negative.
fn isnormal
fn isnormal(n: types::floating) bool;
Returns true if the given floating-point number is normal.
fn isnormalf32
fn isnormalf32(n: f32) bool;
Returns true if the given f32 is normal.
fn isnormalf64
fn isnormalf64(n: f64) bool;
Returns true if the given f64 is normal.
fn ispositive
fn ispositive(x: types::floating) bool;
Returns whether or not x is positive.
fn ispositivef32
fn ispositivef32(x: f32) bool;
Returns whether or not x is positive.
fn ispositivef64
fn ispositivef64(x: f64) bool;
Returns whether or not x is positive.
fn issubnormal
fn issubnormal(n: types::floating) bool;
Returns true if the given floating-point number is subnormal.
fn issubnormalf32
fn issubnormalf32(n: f32) bool;
Returns true if the given f32 is subnormal.
fn issubnormalf64
fn issubnormalf64(n: f64) bool;
Returns true if the given f64 is subnormal.
fn ldexpf32
fn ldexpf32(mantissa: f32, exp: i64) f32;
Creates an f32 from a mantissa and an exponent.
fn ldexpf64
fn ldexpf64(mantissa: f64, exp: i64) f64;
Creates an f64 from a mantissa and an exponent.
fn leading_zeros_u
fn leading_zeros_u(x: uint) u8;
Returns the number of leading zero bits in x The result is UINT_SIZE for x == 0.
fn leading_zeros_u16
fn leading_zeros_u16(x: u16) u8;
Returns the number of leading zero bits in x The result is 16 for x == 0.
fn leading_zeros_u32
fn leading_zeros_u32(x: u32) u8;
Returns the number of leading zero bits in x The result is 32 for x == 0.
fn leading_zeros_u64
fn leading_zeros_u64(x: u64) u8;
Returns the number of leading zero bits in x The result is 64 for x == 0.
fn leading_zeros_u8
fn leading_zeros_u8(x: u8) u8;
Returns the number of leading zero bits in x The result is 8 for x == 0.
fn log10f64
fn log10f64(x: f64) f64;
Returns the decimal logarithm of x.
fn log1pf64
fn log1pf64(x: f64) f64;
Returns the natural logarithm of 1 plus its argument x. It is more accurate than log(1 + x) when x is near zero.
fn log2f64
fn log2f64(x: f64) f64;
Returns the binary logarithm of x.
fn logf64
fn logf64(x: f64) f64;
Returns the natural logarithm of x.
fn modf64
fn modf64(x: f64, y: f64) f64;
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.
fn modfracf32
fn modfracf32(n: f32) (f32, f32);
Returns the integer and fractional parts of an f32.
fn modfracf64
fn modfracf64(n: f64) (f64, f64);
Returns the integer and fractional parts of an f64.
fn mulu
fn mulu(x: uint, y: uint) (uint, uint);
Calls either mulu32() or mulu64() depending on size(uint).
fn mulu32
fn mulu32(x: u32, y: u32) (u32, u32);
Returns the 64-bit product of x and y: (hi, lo) = x * y with the product bits' upper half returned in hi and the lower half returned in lo.
fn mulu64
fn mulu64(x: u64, y: u64) (u64, u64);
Returns the 128-bit product of x and y: (hi, lo) = x * y with the product bits' upper half returned in hi and the lower half returned in lo.
fn nextafterf32
fn nextafterf32(x: f32, y: f32) f32;
Returns the f32 that is closest to 'x' in direction of 'y'. Returns NaN if either parameter is NaN. Returns 'x' if both parameters are same.
fn nextafterf64
fn nextafterf64(x: f64, y: f64) f64;
Returns the f64 that is closest to 'x' in direction of 'y' Returns NaN if either parameter is NaN. Returns 'x' if both parameters are same.
fn normalizef32
fn normalizef32(n: f32) (f32, i64);
Takes a potentially subnormal f32 n and returns a normal f32 normal_float and an exponent exp such that n == normal_float * 2^{exp}.
fn normalizef64
fn normalizef64(n: f64) (f64, i64);
Takes a potentially subnormal f64 n and returns a normal f64 normal_float and an exponent exp such that n == normal_float * 2^{exp}.
fn popcount
fn popcount(x: u64) u8;
Returns the number of bits set (the population count) of x.
fn powf64
fn powf64(x: f64, p: f64) f64;
Returns x^p.
fn raiseexcept
fn raiseexcept(ex: fexcept) void;
Accepts a set of flags from fexcept ORed together and raises exceptions corresponding to the given flags.
fn remu
fn remu(hi: uint, lo: uint, y: uint) uint;
Calls either remu32() or remu64() depending on size(uint).
fn remu32
fn remu32(hi: u32, lo: u32, y: u32) u32;
Returns the remainder of (hi, lo) divided by y. Panics for y == 0 (division by zero) but, unlike divu(), it doesn't panic on a quotient overflow.
fn remu64
fn remu64(hi: u64, lo: u64, y: u64) u64;
Returns the remainder of (hi, lo) divided by y. Panics for y == 0 (division by zero) but, unlike divu(), it doesn't panic on a quotient overflow.
fn roundf64
fn roundf64(x: f64) f64;
Returns the nearest integer, rounding half away from zero.
fn setround
fn setround(mode: fround) void;
Sets the rounding mode to the specified value
fn signf
fn signf(x: types::floating) i64;
Returns 1 if x is positive and -1 if x is negative. Note that zero is also signed.
fn signf32
fn signf32(x: f32) i64;
Returns 1 if x is positive and -1 if x is negative. Note that zero is also signed.
fn signf64
fn signf64(x: f64) i64;
Returns 1 if x is positive and -1 if x is negative. Note that zero is also signed.
fn signi
fn signi(n: types::signed) i64;
Return 1 if n is positive, -1 if it's negative and 0 if it's 0.
fn signi16
fn signi16(n: i16) i16;
Return 1 if n is positive, -1 if it's negative and 0 if it's 0.
fn signi32
fn signi32(n: i32) i32;
Return 1 if n is positive, -1 if it's negative and 0 if it's 0.
fn signi64
fn signi64(n: i64) i64;
Return 1 if n is positive, -1 if it's negative and 0 if it's 0.
fn signi8
fn signi8(n: i8) i8;
Return 1 if n is positive, -1 if it's negative and 0 if it's 0.
fn sinf64
fn sinf64(x: f64) f64;
Returns the sine of x, in radians.
fn sinhf64
fn sinhf64(x: f64) f64;
Returns the hyperbolic sine of x.
fn sqrtf64
fn sqrtf64(x: f64) f64;
Returns the square root of x.
fn subu
fn subu(x: uint, y: uint, carry: uint) (uint, uint);
Calls either mulu32() or mulu64() depending on size(uint).
fn subu32
fn subu32(x: u32, y: u32, borrow: u32) (u32, u32);
Returns the difference of x, y and borrow, diff = x - y - borrow. The borrow input must be 0 or 1, otherwise the behavior is undefined. The borrow_out output is guaranteed to be 0 or 1.
fn subu64
fn subu64(x: u64, y: u64, borrow: u64) (u64, u64);
Returns the difference of x, y and borrow, diff = x - y - borrow. The borrow input must be 0 or 1, otherwise the behavior is undefined. The borrow_out output is guaranteed to be 0 or 1.
fn tanf64
fn tanf64(x: f64) f64;
Returns the tangent of x, in radians.
fn tanhf64
fn tanhf64(x: f64) f64;
Returns the hyperbolic tangent of x.
fn testexcept
fn testexcept(ex: fexcept) fexcept;
Accepts a set of flags from fexcept ORed together and returns the subset that is currently raised
fn trailing_zeros_u
fn trailing_zeros_u(x: uint) u8;
Returns the number of trailing zero bits in x The result is UINT_SIZE for x == 0.
fn trailing_zeros_u16
fn trailing_zeros_u16(x: u16) u8;
Returns the number of trailing zero bits in x The result is 16 for x == 0.
fn trailing_zeros_u32
fn trailing_zeros_u32(x: u32) u8;
Returns the number of trailing zero bits in x The result is 32 for x == 0.
fn trailing_zeros_u64
fn trailing_zeros_u64(x: u64) u8;
Returns the number of trailing zero bits in x The result is 64 for x == 0.
fn trailing_zeros_u8
fn trailing_zeros_u8(x: u8) u8;
Returns the number of trailing zero bits in x The result is 8 for x == 0.
fn truncf64
fn truncf64(x: f64) f64;
Returns the integer value of x.