An interface for numeric types
FPCategory
- Used for representing the classification of floating point numbersAlgebraic
BitCount
Bitwise
- Collects the bitwise operators under one trait.Bounded
Exponential
Float
- Primitive floating point numbersFractional
FromStrRadix
Hyperbolic
Int
- A collection of traits relevant to primitive signed and unsigned integersIntConvertible
Integer
Num
- The base trait for numeric typesNumCast
- An interface for casting between machine scalarsOne
Orderable
Primitive
- Specifies the available operations common to all of Rust's core numeric primitivesReal
- Defines constants and methods common to real numbersRealExt
- Methods that are harder to implement and not commonly used.Round
Signed
ToStrRadix
Trigonometric
Unsigned
Zero
of ::std::cmp::Eq for FPCategory
- Automatically derived.of NumCast for u8
of NumCast for u16
of NumCast for u32
of NumCast for u64
of NumCast for uint
of NumCast for i8
of NumCast for i16
of NumCast for i32
of NumCast for i64
of NumCast for int
of NumCast for f32
of NumCast for f64
of NumCast for float
of Zero for @mut T where <T: Zero>
of Zero for @T where <T: Zero>
of Zero for ~T where <T: Zero>
abs
cast
- Cast from one machine scalar to anotherpow_with_uint
- Calculates a power to a given radix, optimized for uint pow
and radix
.num::strconv
FPCategory
Used for representing the classification of floating point numbers
FPNaN
- "Not a Number", often obtained by dividing by zero
FPInfinite
- Positive or negative infinity
FPZero
- Positive or negative zero
FPSubnormal
- De-normalized floating point representation (less precise than FPNormal
)
FPNormal
- A regular floating point number
Algebraic
pow
fn pow(&self, n: &Self) -> Self
sqrt
fn sqrt(&self) -> Self
rsqrt
fn rsqrt(&self) -> Self
cbrt
fn cbrt(&self) -> Self
hypot
fn hypot(&self, other: &Self) -> Self
BitCount
population_count
fn population_count(&self) -> Self
leading_zeros
fn leading_zeros(&self) -> Self
trailing_zeros
fn trailing_zeros(&self) -> Self
Bitwise
Collects the bitwise operators under one trait.
Bounded
min_value
fn min_value() -> Self
max_value
fn max_value() -> Self
Exponential
exp
fn exp(&self) -> Self
exp2
fn exp2(&self) -> Self
ln
fn ln(&self) -> Self
log
fn log(&self, base: &Self) -> Self
log2
fn log2(&self) -> Self
log10
fn log10(&self) -> Self
Float
Primitive floating point numbers
NaN
fn NaN() -> Self
infinity
fn infinity() -> Self
neg_infinity
fn neg_infinity() -> Self
neg_zero
fn neg_zero() -> Self
is_NaN
fn is_NaN(&self) -> bool
is_infinite
fn is_infinite(&self) -> bool
is_finite
fn is_finite(&self) -> bool
is_normal
fn is_normal(&self) -> bool
classify
fn classify(&self) -> FPCategory
mantissa_digits
fn mantissa_digits() -> uint
digits
fn digits() -> uint
epsilon
fn epsilon() -> Self
min_exp
fn min_exp() -> int
max_exp
fn max_exp() -> int
min_10_exp
fn min_10_exp() -> int
max_10_exp
fn max_10_exp() -> int
ldexp
fn ldexp(x: Self, exp: int) -> Self
frexp
fn frexp(&self) -> (Self, int)
exp_m1
fn exp_m1(&self) -> Self
ln_1p
fn ln_1p(&self) -> Self
mul_add
fn mul_add(&self, a: Self, b: Self) -> Self
next_after
fn next_after(&self, other: Self) -> Self
Fractional
recip
fn recip(&self) -> Self
FromStrRadix
from_str_radix
fn from_str_radix(str: &str, radix: uint) -> Option<Self>
Hyperbolic
sinh
fn sinh(&self) -> Self
cosh
fn cosh(&self) -> Self
tanh
fn tanh(&self) -> Self
asinh
fn asinh(&self) -> Self
acosh
fn acosh(&self) -> Self
atanh
fn atanh(&self) -> Self
Int
A collection of traits relevant to primitive signed and unsigned integers
IntConvertible
to_int
fn to_int(&self) -> int
from_int
fn from_int(n: int) -> Self
Integer
div_rem
fn div_rem(&self, other: &Self) -> (Self, Self)
div_floor
fn div_floor(&self, other: &Self) -> Self
mod_floor
fn mod_floor(&self, other: &Self) -> Self
div_mod_floor
fn div_mod_floor(&self, other: &Self) -> (Self, Self)
gcd
fn gcd(&self, other: &Self) -> Self
lcm
fn lcm(&self, other: &Self) -> Self
is_multiple_of
fn is_multiple_of(&self, other: &Self) -> bool
is_even
fn is_even(&self) -> bool
is_odd
fn is_odd(&self) -> bool
Num
The base trait for numeric types
NumCast
An interface for casting between machine scalars
from
fn from<T: NumCast>(n: T) -> Self
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
One
one
fn one() -> Self
Orderable
min
fn min(&self, other: &Self) -> Self
max
fn max(&self, other: &Self) -> Self
clamp
fn clamp(&self, mn: &Self, mx: &Self) -> Self
Primitive
Specifies the available operations common to all of Rust's core numeric primitives. These may not always make sense from a purely mathematical point of view, but may be useful for systems programming.
bits
fn bits() -> uint
bytes
fn bytes() -> uint
Real
Defines constants and methods common to real numbers
pi
fn pi() -> Self
two_pi
fn two_pi() -> Self
frac_pi_2
fn frac_pi_2() -> Self
frac_pi_3
fn frac_pi_3() -> Self
frac_pi_4
fn frac_pi_4() -> Self
frac_pi_6
fn frac_pi_6() -> Self
frac_pi_8
fn frac_pi_8() -> Self
frac_1_pi
fn frac_1_pi() -> Self
frac_2_pi
fn frac_2_pi() -> Self
frac_2_sqrtpi
fn frac_2_sqrtpi() -> Self
sqrt2
fn sqrt2() -> Self
frac_1_sqrt2
fn frac_1_sqrt2() -> Self
e
fn e() -> Self
log2_e
fn log2_e() -> Self
log10_e
fn log10_e() -> Self
ln_2
fn ln_2() -> Self
ln_10
fn ln_10() -> Self
to_degrees
fn to_degrees(&self) -> Self
to_radians
fn to_radians(&self) -> Self
RealExt
Methods that are harder to implement and not commonly used.
lgamma
fn lgamma(&self) -> (int, Self)
tgamma
fn tgamma(&self) -> Self
j0
fn j0(&self) -> Self
j1
fn j1(&self) -> Self
jn
fn jn(&self, n: int) -> Self
y0
fn y0(&self) -> Self
y1
fn y1(&self) -> Self
yn
fn yn(&self, n: int) -> Self
Round
floor
fn floor(&self) -> Self
ceil
fn ceil(&self) -> Self
round
fn round(&self) -> Self
trunc
fn trunc(&self) -> Self
fract
fn fract(&self) -> Self
Signed
abs
fn abs(&self) -> Self
abs_sub
fn abs_sub(&self, other: &Self) -> Self
signum
fn signum(&self) -> Self
is_positive
fn is_positive(&self) -> bool
is_negative
fn is_negative(&self) -> bool
ToStrRadix
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str
Trigonometric
sin
fn sin(&self) -> Self
cos
fn cos(&self) -> Self
tan
fn tan(&self) -> Self
asin
fn asin(&self) -> Self
acos
fn acos(&self) -> Self
atan
fn atan(&self) -> Self
atan2
fn atan2(&self, other: &Self) -> Self
sin_cos
fn sin_cos(&self) -> (Self, Self)
Unsigned
Zero
zero
fn zero() -> Self
is_zero
fn is_zero(&self) -> bool
::std::cmp::Eq
for FPCategory
Automatically derived.
eq
fn eq(&self, __arg_0: &FPCategory) -> ::bool
ne
fn ne(&self, __arg_0: &FPCategory) -> ::bool
NumCast
for u8
from
fn from<N: NumCast>(n: N) -> u8
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for u16
from
fn from<N: NumCast>(n: N) -> u16
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for u32
from
fn from<N: NumCast>(n: N) -> u32
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for u64
from
fn from<N: NumCast>(n: N) -> u64
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for uint
from
fn from<N: NumCast>(n: N) -> uint
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for i8
from
fn from<N: NumCast>(n: N) -> i8
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for i16
from
fn from<N: NumCast>(n: N) -> i16
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for i32
from
fn from<N: NumCast>(n: N) -> i32
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for i64
from
fn from<N: NumCast>(n: N) -> i64
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for int
from
fn from<N: NumCast>(n: N) -> int
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for f32
from
fn from<N: NumCast>(n: N) -> f32
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for f64
from
fn from<N: NumCast>(n: N) -> f64
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
NumCast
for float
from
fn from<N: NumCast>(n: N) -> float
to_u8
fn to_u8(&self) -> u8
to_u16
fn to_u16(&self) -> u16
to_u32
fn to_u32(&self) -> u32
to_u64
fn to_u64(&self) -> u64
to_uint
fn to_uint(&self) -> uint
to_i8
fn to_i8(&self) -> i8
to_i16
fn to_i16(&self) -> i16
to_i32
fn to_i32(&self) -> i32
to_i64
fn to_i64(&self) -> i64
to_int
fn to_int(&self) -> int
to_f32
fn to_f32(&self) -> f32
to_f64
fn to_f64(&self) -> f64
to_float
fn to_float(&self) -> float
Zero
for @mut T
where <T: Zero>
zero
fn zero() -> @mut T
is_zero
fn is_zero(&self) -> bool
Zero
for @T
where <T: Zero>
zero
fn zero() -> @T
is_zero
fn is_zero(&self) -> bool
Zero
for ~T
where <T: Zero>
zero
fn zero() -> ~T
is_zero
fn is_zero(&self) -> bool
abs
fn abs<T: Ord + Zero + Neg<T>>(v: T) -> T
cast
fn cast<T: NumCast, U: NumCast>(n: T) -> U
Cast from one machine scalar to another
let twenty: f32 = num::cast(0x14);
assert_eq!(twenty, 20f32);
pow_with_uint
fn pow_with_uint<T: NumCast + One + Zero + Copy + Div<T, T> +
Mul<T, T>>(radix: uint, pow: uint) -> T
Calculates a power to a given radix, optimized for uint pow
and radix
.
Returns radix^pow
as T
.
Note: Also returns 1
for 0^0
, despite that technically being an undefined number. The reason for this is twofold: - If code written to use this function cares about that special case, it's probably going to catch it before making the call. - If code written to use this function doesn't care about it, it's probably assuming that x^0
always equals 1
.