Operations and constants for f32
NaN
infinity
neg_infinity
of Num for f32
of Eq for f32
of ApproxEq<f32> for f32
of Ord for f32
of Orderable for f32
of Zero for f32
of One for f32
of Add<f32, f32> for f32
of Sub<f32, f32> for f32
of Mul<f32, f32> for f32
of Div<f32, f32> for f32
of Rem<f32, f32> for f32
of Neg<f32> for f32
of Signed for f32
of Round for f32
of Fractional for f32
of Algebraic for f32
of Trigonometric for f32
of Exponential for f32
of Hyperbolic for f32
of Real for f32
of Bounded for f32
of Primitive for f32
of Float for f32
of to_str::ToStr for f32
of num::ToStrRadix for f32
of FromStr for f32
of num::FromStrRadix for f32
add
div
eq
fmax
fmin
from_str
- Convert a string in base 10 to a floatfrom_str_hex
- Convert a string in base 16 to a floatfrom_str_radix
- Convert a string in an given base to a float.ge
gt
le
lt
mul
ne
rem
sub
to_str
- Converts a float to a stringto_str_digits
- Converts a float to a string with a maximum number of significant digitsto_str_exact
- Converts a float to a string with exactly the number of provided significant digitsto_str_hex
- Converts a float to a string in hexadecimal formatto_str_radix
- Converts a float to a string in a given radixto_str_radix_special
- Converts a float to a string in a given radix, and a flag indicating whether it's a special valuef32::consts
NaN
f32
infinity
f32
neg_infinity
f32
Num
for f32
Eq
for f32
eq
fn eq(&self, other: &f32) -> bool
ne
fn ne(&self, other: &f32) -> bool
ApproxEq<f32>
for f32
approx_epsilon
fn approx_epsilon() -> f32
approx_eq
fn approx_eq(&self, other: &f32) -> bool
approx_eq_eps
fn approx_eq_eps(&self, other: &f32, approx_epsilon: &f32) -> bool
Ord
for f32
lt
fn lt(&self, other: &f32) -> bool
le
fn le(&self, other: &f32) -> bool
ge
fn ge(&self, other: &f32) -> bool
gt
fn gt(&self, other: &f32) -> bool
Orderable
for f32
min
fn min(&self, other: &f32) -> f32
Returns NaN
if either of the numbers are NaN
.
max
fn max(&self, other: &f32) -> f32
Returns NaN
if either of the numbers are NaN
.
clamp
fn clamp(&self, mn: &f32, mx: &f32) -> f32
Returns the number constrained within the range mn <= self <= mx
. If any of the numbers are NaN
then NaN
is returned.
Zero
for f32
zero
fn zero() -> f32
is_zero
fn is_zero(&self) -> bool
Returns true if the number is equal to either 0.0
or -0.0
One
for f32
one
fn one() -> f32
Add<f32, f32>
for f32
add
fn add(&self, other: &f32) -> f32
Sub<f32, f32>
for f32
sub
fn sub(&self, other: &f32) -> f32
Mul<f32, f32>
for f32
mul
fn mul(&self, other: &f32) -> f32
Div<f32, f32>
for f32
div
fn div(&self, other: &f32) -> f32
Rem<f32, f32>
for f32
rem
fn rem(&self, other: &f32) -> f32
Neg<f32>
for f32
neg
fn neg(&self) -> f32
Signed
for f32
abs
fn abs(&self) -> f32
Computes the absolute value. Returns NaN
if the number is NaN
.
abs_sub
fn abs_sub(&self, other: &f32) -> f32
The positive difference of two numbers. Returns 0.0
if the number is less than or equal to other
, otherwise the difference betweenself
and other
is returned.
signum
fn signum(&self) -> f32
1.0
if the number is positive, +0.0
or infinity
-1.0
if the number is negative, -0.0
or neg_infinity
NaN
if the number is NaNis_positive
fn is_positive(&self) -> bool
Returns true
if the number is positive, including +0.0
and infinity
is_negative
fn is_negative(&self) -> bool
Returns true
if the number is negative, including -0.0
and neg_infinity
Round
for f32
floor
fn floor(&self) -> f32
Round half-way cases toward neg_infinity
ceil
fn ceil(&self) -> f32
Round half-way cases toward infinity
round
fn round(&self) -> f32
Round half-way cases away from 0.0
trunc
fn trunc(&self) -> f32
The integer part of the number (rounds towards 0.0
)
fract
fn fract(&self) -> f32
The fractional part of the number, satisfying:
assert!(x == trunc(x) + fract(x))
Fractional
for f32
recip
fn recip(&self) -> f32
The reciprocal (multiplicative inverse) of the number
Algebraic
for f32
pow
fn pow(&self, n: &f32) -> f32
sqrt
fn sqrt(&self) -> f32
rsqrt
fn rsqrt(&self) -> f32
cbrt
fn cbrt(&self) -> f32
hypot
fn hypot(&self, other: &f32) -> f32
Trigonometric
for f32
sin
fn sin(&self) -> f32
cos
fn cos(&self) -> f32
tan
fn tan(&self) -> f32
asin
fn asin(&self) -> f32
acos
fn acos(&self) -> f32
atan
fn atan(&self) -> f32
atan2
fn atan2(&self, other: &f32) -> f32
sin_cos
fn sin_cos(&self) -> (f32, f32)
Simultaneously computes the sine and cosine of the number
Exponential
for f32
exp
fn exp(&self) -> f32
Returns the exponential of the number
exp2
fn exp2(&self) -> f32
Returns 2 raised to the power of the number
ln
fn ln(&self) -> f32
Returns the natural logarithm of the number
log
fn log(&self, base: &f32) -> f32
Returns the logarithm of the number with respect to an arbitrary base
log2
fn log2(&self) -> f32
Returns the base 2 logarithm of the number
log10
fn log10(&self) -> f32
Returns the base 10 logarithm of the number
Hyperbolic
for f32
sinh
fn sinh(&self) -> f32
cosh
fn cosh(&self) -> f32
tanh
fn tanh(&self) -> f32
asinh
fn asinh(&self) -> f32
Inverse hyperbolic sine
self
will be returnedself
if self
is 0.0
, -0.0
, infinity
, or neg_infinity
NaN
if self
is NaN
acosh
fn acosh(&self) -> f32
Inverse hyperbolic cosine
self
will be returnedinfinity
if self
is infinity
NaN
if self
is NaN
or self < 1.0
(including neg_infinity
)atanh
fn atanh(&self) -> f32
Inverse hyperbolic tangent
self
will be returnedself
if self
is 0.0
or -0.0
infinity
if self
is 1.0
neg_infinity
if self
is -1.0
NaN
if the self
is NaN
or outside the domain of -1.0 <= self <= 1.0
(including infinity
and neg_infinity
)Real
for f32
pi
fn pi() -> f32
Archimedes' constant
two_pi
fn two_pi() -> f32
2.0 * pi
frac_pi_2
fn frac_pi_2() -> f32
pi / 2.0
frac_pi_3
fn frac_pi_3() -> f32
pi / 3.0
frac_pi_4
fn frac_pi_4() -> f32
pi / 4.0
frac_pi_6
fn frac_pi_6() -> f32
pi / 6.0
frac_pi_8
fn frac_pi_8() -> f32
pi / 8.0
frac_1_pi
fn frac_1_pi() -> f32
1 .0/ pi
frac_2_pi
fn frac_2_pi() -> f32
2.0 / pi
frac_2_sqrtpi
fn frac_2_sqrtpi() -> f32
2.0 / sqrt(pi)
sqrt2
fn sqrt2() -> f32
sqrt(2.0)
frac_1_sqrt2
fn frac_1_sqrt2() -> f32
1.0 / sqrt(2.0)
e
fn e() -> f32
Euler's number
log2_e
fn log2_e() -> f32
log2(e)
log10_e
fn log10_e() -> f32
log10(e)
ln_2
fn ln_2() -> f32
ln(2.0)
ln_10
fn ln_10() -> f32
ln(10.0)
to_degrees
fn to_degrees(&self) -> f32
Converts to degrees, assuming the number is in radians
to_radians
fn to_radians(&self) -> f32
Converts to radians, assuming the number is in degrees
Bounded
for f32
min_value
fn min_value() -> f32
max_value
fn max_value() -> f32
Primitive
for f32
bits
fn bits() -> uint
bytes
fn bytes() -> uint
Float
for f32
NaN
fn NaN() -> f32
infinity
fn infinity() -> f32
neg_infinity
fn neg_infinity() -> f32
neg_zero
fn neg_zero() -> f32
is_NaN
fn is_NaN(&self) -> bool
Returns true
if the number is NaN
is_infinite
fn is_infinite(&self) -> bool
Returns true
if the number is infinite
is_finite
fn is_finite(&self) -> bool
Returns true
if the number is neither infinite or NaN
is_normal
fn is_normal(&self) -> bool
Returns true
if the number is neither zero, infinite, subnormal or NaN
classify
fn classify(&self) -> FPCategory
Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.
mantissa_digits
fn mantissa_digits() -> uint
digits
fn digits() -> uint
epsilon
fn epsilon() -> f32
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: f32, exp: int) -> f32
Constructs a floating point number by multiplying x
by 2 raised to the power of exp
frexp
fn frexp(&self) -> (f32, int)
Breaks the number into a normalized fraction and a base-2 exponent, satisfying:
self = x * pow(2, exp)
0.5 <= abs(x) < 1.0
exp_m1
fn exp_m1(&self) -> f32
Returns the exponential of the number, minus 1
, in a way that is accurate even if the number is close to zero
ln_1p
fn ln_1p(&self) -> f32
Returns the natural logarithm of the number plus 1
(ln(1+n)
) more accurately than if the operations were performed separately
mul_add
fn mul_add(&self, a: f32, b: f32) -> f32
Fused multiply-add. Computes (self * a) + b
with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add.
next_after
fn next_after(&self, other: f32) -> f32
Returns the next representable floating-point value in the direction of other
to_str::ToStr
for f32
to_str
fn to_str(&self) -> ~str
num::ToStrRadix
for f32
to_str_radix
fn to_str_radix(&self, rdx: uint) -> ~str
FromStr
for f32
from_str
fn from_str(val: &str) -> Option<f32>
num::FromStrRadix
for f32
from_str_radix
fn from_str_radix(val: &str, rdx: uint) -> Option<f32>
add
fn add(x: f32, y: f32) -> f32
div
fn div(x: f32, y: f32) -> f32
eq
fn eq(x: f32, y: f32) -> bool
fmax
fn fmax(x: f32, y: f32) -> f32
fmin
fn fmin(x: f32, y: f32) -> f32
from_str
fn from_str(num: &str) -> Option<f32>
Convert a string in base 10 to a float. Accepts a optional decimal exponent.
This function accepts strings such as
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by num
.
from_str_hex
fn from_str_hex(num: &str) -> Option<f32>
Convert a string in base 16 to a float. Accepts a optional binary exponent.
This function accepts strings such as
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by [num]
.
from_str_radix
fn from_str_radix(num: &str, rdx: uint) -> Option<f32>
Convert a string in an given base to a float.
Due to possible conflicts, this function does not accept the special values inf
, -inf
, +inf
and NaN
, nor does it recognize exponents of any kind.
Leading and trailing whitespace represent an error.
none
if the string did not represent a valid number. Otherwise, Some(n)
where n
is the floating-point number represented by num
.
ge
fn ge(x: f32, y: f32) -> bool
gt
fn gt(x: f32, y: f32) -> bool
le
fn le(x: f32, y: f32) -> bool
lt
fn lt(x: f32, y: f32) -> bool
mul
fn mul(x: f32, y: f32) -> f32
ne
fn ne(x: f32, y: f32) -> bool
rem
fn rem(x: f32, y: f32) -> f32
sub
fn sub(x: f32, y: f32) -> f32
to_str
fn to_str(num: f32) -> ~str
Converts a float to a string
to_str_digits
fn to_str_digits(num: f32, dig: uint) -> ~str
Converts a float to a string with a maximum number of significant digits
to_str_exact
fn to_str_exact(num: f32, dig: uint) -> ~str
Converts a float to a string with exactly the number of provided significant digits
to_str_hex
fn to_str_hex(num: f32) -> ~str
Converts a float to a string in hexadecimal format
to_str_radix
fn to_str_radix(num: f32, rdx: uint) -> ~str
Converts a float to a string in a given radix
Fails if called on a special value like inf
, -inf
or NaN
due to possible misinterpretation of the result at higher bases. If those values are expected, use to_str_radix_special()
instead.
to_str_radix_special
fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool)
Converts a float to a string in a given radix, and a flag indicating whether it's a special value