Operations and constants for float

Freeze NaN

float

Freeze infinity

float

Freeze neg_infinity

float

Implementation of to_str::ToStr for float

Method to_str

fn to_str(&self) -> ~str

Implementation of num::ToStrRadix for float

Method to_str_radix

fn to_str_radix(&self, radix: uint) -> ~str

Implementation of FromStr for float

Method from_str

fn from_str(val: &str) -> Option<float>

Implementation of num::FromStrRadix for float

Method from_str_radix

fn from_str_radix(val: &str, radix: uint) -> Option<float>

Implementation of Num for float

Implementation of Eq for float

Method eq

fn eq(&self, other: &float) -> bool

Method ne

fn ne(&self, other: &float) -> bool

Implementation of ApproxEq<float> for float

Method approx_epsilon

fn approx_epsilon() -> float

Method approx_eq

fn approx_eq(&self, other: &float) -> bool

Method approx_eq_eps

fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool

Implementation of Ord for float

Method lt

fn lt(&self, other: &float) -> bool

Method le

fn le(&self, other: &float) -> bool

Method ge

fn ge(&self, other: &float) -> bool

Method gt

fn gt(&self, other: &float) -> bool

Implementation of Orderable for float

Method min

fn min(&self, other: &float) -> float

Returns NaN if either of the numbers are NaN.

Method max

fn max(&self, other: &float) -> float

Returns NaN if either of the numbers are NaN.

Method clamp

fn clamp(&self, mn: &float, mx: &float) -> float

Returns the number constrained within the range mn <= self <= mx. If any of the numbers are NaN then NaN is returned.

Implementation of Zero for float

Method zero

fn zero() -> float

Method is_zero

fn is_zero(&self) -> bool

Returns true if the number is equal to either 0.0 or -0.0

Implementation of One for float

Method one

fn one() -> float

Implementation of Round for float

Method floor

fn floor(&self) -> float

Round half-way cases toward neg_infinity

Method ceil

fn ceil(&self) -> float

Round half-way cases toward infinity

Method round

fn round(&self) -> float

Round half-way cases away from 0.0

Method trunc

fn trunc(&self) -> float

The integer part of the number (rounds towards 0.0)

Method fract

fn fract(&self) -> float

The fractional part of the number, satisfying:

assert!(x == trunc(x) + fract(x))

Implementation of Fractional for float

Method recip

fn recip(&self) -> float

The reciprocal (multiplicative inverse) of the number

Implementation of Algebraic for float

Method pow

fn pow(&self, n: &float) -> float

Method sqrt

fn sqrt(&self) -> float

Method rsqrt

fn rsqrt(&self) -> float

Method cbrt

fn cbrt(&self) -> float

Method hypot

fn hypot(&self, other: &float) -> float

Implementation of Trigonometric for float

Method sin

fn sin(&self) -> float

Method cos

fn cos(&self) -> float

Method tan

fn tan(&self) -> float

Method asin

fn asin(&self) -> float

Method acos

fn acos(&self) -> float

Method atan

fn atan(&self) -> float

Method atan2

fn atan2(&self, other: &float) -> float

Method sin_cos

fn sin_cos(&self) -> (float, float)

Simultaneously computes the sine and cosine of the number

Implementation of Exponential for float

Method exp

fn exp(&self) -> float

Returns the exponential of the number

Method exp2

fn exp2(&self) -> float

Returns 2 raised to the power of the number

Method ln

fn ln(&self) -> float

Returns the natural logarithm of the number

Method log

fn log(&self, base: &float) -> float

Returns the logarithm of the number with respect to an arbitrary base

Method log2

fn log2(&self) -> float

Returns the base 2 logarithm of the number

Method log10

fn log10(&self) -> float

Returns the base 10 logarithm of the number

Implementation of Hyperbolic for float

Method sinh

fn sinh(&self) -> float

Method cosh

fn cosh(&self) -> float

Method tanh

fn tanh(&self) -> float

Method asinh

fn asinh(&self) -> float

Inverse hyperbolic sine

Returns

  • on success, the inverse hyperbolic sine of self will be returned
  • self if self is 0.0, -0.0, infinity, or neg_infinity
  • NaN if self is NaN

Method acosh

fn acosh(&self) -> float

Inverse hyperbolic cosine

Returns

  • on success, the inverse hyperbolic cosine of self will be returned
  • infinity if self is infinity
  • NaN if self is NaN or self < 1.0 (including neg_infinity)

Method atanh

fn atanh(&self) -> float

Inverse hyperbolic tangent

Returns

  • on success, the inverse hyperbolic tangent of self will be returned
  • self 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)

Implementation of Real for float

Method pi

fn pi() -> float

Archimedes' constant

Method two_pi

fn two_pi() -> float

2.0 * pi

Method frac_pi_2

fn frac_pi_2() -> float

pi / 2.0

Method frac_pi_3

fn frac_pi_3() -> float

pi / 3.0

Method frac_pi_4

fn frac_pi_4() -> float

pi / 4.0

Method frac_pi_6

fn frac_pi_6() -> float

pi / 6.0

Method frac_pi_8

fn frac_pi_8() -> float

pi / 8.0

Method frac_1_pi

fn frac_1_pi() -> float

1.0 / pi

Method frac_2_pi

fn frac_2_pi() -> float

2.0 / pi

Method frac_2_sqrtpi

fn frac_2_sqrtpi() -> float

2 .0/ sqrt(pi)

Method sqrt2

fn sqrt2() -> float

sqrt(2.0)

Method frac_1_sqrt2

fn frac_1_sqrt2() -> float

1.0 / sqrt(2.0)

Method e

fn e() -> float

Euler's number

Method log2_e

fn log2_e() -> float

log2(e)

Method log10_e

fn log10_e() -> float

log10(e)

Method ln_2

fn ln_2() -> float

ln(2.0)

Method ln_10

fn ln_10() -> float

ln(10.0)

Method to_degrees

fn to_degrees(&self) -> float

Converts to degrees, assuming the number is in radians

Method to_radians

fn to_radians(&self) -> float

Converts to radians, assuming the number is in degrees

Implementation of RealExt for float

Method lgamma

fn lgamma(&self) -> (int, float)

Method tgamma

fn tgamma(&self) -> float

Method j0

fn j0(&self) -> float

Method j1

fn j1(&self) -> float

Method jn

fn jn(&self, n: int) -> float

Method y0

fn y0(&self) -> float

Method y1

fn y1(&self) -> float

Method yn

fn yn(&self, n: int) -> float

Implementation of Add<float, float> for float

Method add

fn add(&self, other: &float) -> float

Implementation of Sub<float, float> for float

Method sub

fn sub(&self, other: &float) -> float

Implementation of Mul<float, float> for float

Method mul

fn mul(&self, other: &float) -> float

Implementation of Div<float, float> for float

Method div

fn div(&self, other: &float) -> float

Implementation of Rem<float, float> for float

Method rem

fn rem(&self, other: &float) -> float

Implementation of Neg<float> for float

Method neg

fn neg(&self) -> float

Implementation of Signed for float

Method abs

fn abs(&self) -> float

Computes the absolute value. Returns NaN if the number is NaN.

Method abs_sub

fn abs_sub(&self, other: &float) -> float

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.

Method signum

fn signum(&self) -> float

Returns

  • 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 NaN

Method is_positive

fn is_positive(&self) -> bool

Returns true if the number is positive, including +0.0 and infinity

Method is_negative

fn is_negative(&self) -> bool

Returns true if the number is negative, including -0.0 and neg_infinity

Implementation of Bounded for float

Method min_value

fn min_value() -> float

Method max_value

fn max_value() -> float

Implementation of Primitive for float

Method bits

fn bits() -> uint

Method bytes

fn bytes() -> uint

Implementation of Float for float

Method NaN

fn NaN() -> float

Method infinity

fn infinity() -> float

Method neg_infinity

fn neg_infinity() -> float

Method neg_zero

fn neg_zero() -> float

Method is_NaN

fn is_NaN(&self) -> bool

Returns true if the number is NaN

Method is_infinite

fn is_infinite(&self) -> bool

Returns true if the number is infinite

Method is_finite

fn is_finite(&self) -> bool

Returns true if the number is neither infinite or NaN

Method is_normal

fn is_normal(&self) -> bool

Returns true if the number is neither zero, infinite, subnormal or NaN

Method 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.

Method mantissa_digits

fn mantissa_digits() -> uint

Method digits

fn digits() -> uint

Method epsilon

fn epsilon() -> float

Method min_exp

fn min_exp() -> int

Method max_exp

fn max_exp() -> int

Method min_10_exp

fn min_10_exp() -> int

Method max_10_exp

fn max_10_exp() -> int

Method ldexp

fn ldexp(x: float, exp: int) -> float

Constructs a floating point number by multiplying x by 2 raised to the power of exp

Method frexp

fn frexp(&self) -> (float, int)

Breaks the number into a normalized fraction and a base-2 exponent, satisfying:

Method exp_m1

fn exp_m1(&self) -> float

Returns the exponential of the number, minus 1, in a way that is accurate even if the number is close to zero

Method ln_1p

fn ln_1p(&self) -> float

Returns the natural logarithm of the number plus 1 (ln(1+n)) more accurately than if the operations were performed separately

Method mul_add

fn mul_add(&self, a: float, b: float) -> float

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.

Method next_after

fn next_after(&self, other: float) -> float

Returns the next representable floating-point value in the direction of other

Function abs

fn abs(x: float) -> float

Function atan

fn atan(x: float) -> float

Function cos

fn cos(x: float) -> float

Function from_str

fn from_str(num: &str) -> Option<float>

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.

Arguments

Return value

none if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by num.

Function from_str_hex

fn from_str_hex(num: &str) -> Option<float>

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.

Arguments

Return value

none if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by [num].

Function from_str_radix

fn from_str_radix(num: &str, radix: uint) -> Option<float>

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.

Arguments

Return value

none if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by num.

Function pow_with_uint

fn pow_with_uint(base: uint, pow: uint) -> float

Compute the exponentiation of an integer by another integer as a float

Arguments

Return value

NaN if both x and pow are 0u, otherwise x^pow

Function sin

fn sin(x: float) -> float

Function sqrt

fn sqrt(x: float) -> float

Function tan

fn tan(x: float) -> float

Function to_str

fn to_str(num: float) -> ~str

Converts a float to a string

Arguments

Function to_str_digits

fn to_str_digits(num: float, digits: uint) -> ~str

Converts a float to a string with a maximum number of significant digits

Arguments

Function to_str_exact

fn to_str_exact(num: float, digits: uint) -> ~str

Converts a float to a string with exactly the number of provided significant digits

Arguments

Function to_str_hex

fn to_str_hex(num: float) -> ~str

Converts a float to a string in hexadecimal format

Arguments

Function to_str_radix

fn to_str_radix(num: float, radix: uint) -> ~str

Converts a float to a string in a given radix

Arguments

Failure

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.

Function to_str_radix_special

fn to_str_radix_special(num: float, radix: uint) -> (~str, bool)

Converts a float to a string in a given radix, and a flag indicating whether it's a special value

Arguments