pub type c_double = f64;
Expand description
Equivalent to C’s double
type.
This type will almost always be f64
, which is guaranteed to be an IEEE 754 double-precision float in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a float
, and it may be f32
or something entirely different from the IEEE-754 standard.
Trait Implementations§
1.22.0 · source§impl AddAssign<&f64> for f64
impl AddAssign<&f64> for f64
source§fn add_assign(&mut self, other: &f64)
fn add_assign(&mut self, other: &f64)
+=
operation. Read more1.8.0 · source§impl AddAssign<f64> for f64
impl AddAssign<f64> for f64
source§fn add_assign(&mut self, other: f64)
fn add_assign(&mut self, other: f64)
+=
operation. Read more1.22.0 · source§impl DivAssign<&f64> for f64
impl DivAssign<&f64> for f64
source§fn div_assign(&mut self, other: &f64)
fn div_assign(&mut self, other: &f64)
/=
operation. Read more1.8.0 · source§impl DivAssign<f64> for f64
impl DivAssign<f64> for f64
source§fn div_assign(&mut self, other: f64)
fn div_assign(&mut self, other: f64)
/=
operation. Read more1.0.0 · source§impl FromStr for f64
impl FromStr for f64
source§fn from_str(src: &str) -> Result<f64, ParseFloatError>
fn from_str(src: &str) -> Result<f64, ParseFloatError>
Converts a string in base 10 to a float. Accepts an optional decimal exponent.
This function accepts strings such as
- ‘3.14’
- ‘-3.14’
- ‘2.5E10’, or equivalently, ‘2.5e10’
- ‘2.5E-10’
- ‘5.’
- ‘.5’, or, equivalently, ‘0.5’
- ‘inf’, ‘-inf’, ‘+infinity’, ‘NaN’
Note that alphabetical characters are not case-sensitive.
Leading and trailing whitespace represent an error.
Grammar
All strings that adhere to the following EBNF grammar when
lowercased will result in an Ok
being returned:
Float ::= Sign? ( 'inf' | 'infinity' | 'nan' | Number )
Number ::= ( Digit+ |
Digit+ '.' Digit* |
Digit* '.' Digit+ ) Exp?
Exp ::= 'e' Sign? Digit+
Sign ::= [+-]
Digit ::= [0-9]
Arguments
- src - A string
Return value
Err(ParseFloatError)
if the string did not represent a valid
number. Otherwise, Ok(n)
where n
is the closest
representable floating-point number to the number represented
by src
(following the same rules for rounding as for the
results of primitive operations).
§type Err = ParseFloatError
type Err = ParseFloatError
1.22.0 · source§impl MulAssign<&f64> for f64
impl MulAssign<&f64> for f64
source§fn mul_assign(&mut self, other: &f64)
fn mul_assign(&mut self, other: &f64)
*=
operation. Read more1.8.0 · source§impl MulAssign<f64> for f64
impl MulAssign<f64> for f64
source§fn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
*=
operation. Read more1.0.0 · source§impl PartialOrd<f64> for f64
impl PartialOrd<f64> for f64
source§fn le(&self, other: &f64) -> bool
fn le(&self, other: &f64) -> bool
self
and other
) and is used by the <=
operator. Read more1.0.0 · source§impl Rem<f64> for f64
impl Rem<f64> for f64
The remainder from the division of two floats.
The remainder has the same sign as the dividend and is computed as:
x - (x / y).trunc() * y
.
Examples
let x: f32 = 50.50;
let y: f32 = 8.125;
let remainder = x - (x / y).trunc() * y;
// The answer to both operations is 1.75
assert_eq!(x % y, remainder);
1.22.0 · source§impl RemAssign<&f64> for f64
impl RemAssign<&f64> for f64
source§fn rem_assign(&mut self, other: &f64)
fn rem_assign(&mut self, other: &f64)
%=
operation. Read more1.8.0 · source§impl RemAssign<f64> for f64
impl RemAssign<f64> for f64
source§fn rem_assign(&mut self, other: f64)
fn rem_assign(&mut self, other: f64)
%=
operation. Read moresource§impl SimdElement for f64
impl SimdElement for f64
1.22.0 · source§impl SubAssign<&f64> for f64
impl SubAssign<&f64> for f64
source§fn sub_assign(&mut self, other: &f64)
fn sub_assign(&mut self, other: &f64)
-=
operation. Read more1.8.0 · source§impl SubAssign<f64> for f64
impl SubAssign<f64> for f64
source§fn sub_assign(&mut self, other: f64)
fn sub_assign(&mut self, other: f64)
-=
operation. Read more