Type Alias tracing::stdlib::ffi::c_float

1.64.0 · source ·
pub type c_float = f32;
Expand description

Equivalent to C’s float type.

This type will almost always be f32, which is guaranteed to be an IEEE 754 single-precision float in Rust. That said, the standard technically only guarantees that it be a floating-point number, and it may have less precision than f32 or not follow the IEEE-754 standard at all.

Trait Implementations§

1.0.0 · source§

impl Add<&f32> for f32

§

type Output = <f32 as Add<f32>>::Output

The resulting type after applying the + operator.
source§

fn add(self, other: &f32) -> <f32 as Add<f32>>::Output

Performs the + operation. Read more
1.0.0 · source§

impl Add<f32> for f32

§

type Output = f32

The resulting type after applying the + operator.
source§

fn add(self, other: f32) -> f32

Performs the + operation. Read more
1.22.0 · source§

impl AddAssign<&f32> for f32

source§

fn add_assign(&mut self, other: &f32)

Performs the += operation. Read more
1.8.0 · source§

impl AddAssign<f32> for f32

source§

fn add_assign(&mut self, other: f32)

Performs the += operation. Read more
1.0.0 · source§

impl Clone for f32

source§

fn clone(&self) -> f32

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.0.0 · source§

impl Debug for f32

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
1.0.0 · source§

impl Default for f32

source§

fn default() -> f32

Returns the default value of 0.0

1.0.0 · source§

impl Display for f32

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
1.0.0 · source§

impl Div<&f32> for f32

§

type Output = <f32 as Div<f32>>::Output

The resulting type after applying the / operator.
source§

fn div(self, other: &f32) -> <f32 as Div<f32>>::Output

Performs the / operation. Read more
1.0.0 · source§

impl Div<f32> for f32

§

type Output = f32

The resulting type after applying the / operator.
source§

fn div(self, other: f32) -> f32

Performs the / operation. Read more
1.22.0 · source§

impl DivAssign<&f32> for f32

source§

fn div_assign(&mut self, other: &f32)

Performs the /= operation. Read more
1.8.0 · source§

impl DivAssign<f32> for f32

source§

fn div_assign(&mut self, other: f32)

Performs the /= operation. Read more
1.68.0 · source§

impl From<bool> for f32

source§

fn from(small: bool) -> f32

Converts bool to f32 losslessly. The resulting value is positive 0.0 for false and 1.0 for true values.

Examples
let x: f32 = false.into();
assert_eq!(x, 0.0);
assert!(x.is_sign_positive());

let y: f32 = true.into();
assert_eq!(y, 1.0);
1.6.0 · source§

impl From<i16> for f32

source§

fn from(small: i16) -> f32

Converts i16 to f32 losslessly.

1.6.0 · source§

impl From<i8> for f32

source§

fn from(small: i8) -> f32

Converts i8 to f32 losslessly.

1.6.0 · source§

impl From<u16> for f32

source§

fn from(small: u16) -> f32

Converts u16 to f32 losslessly.

1.6.0 · source§

impl From<u8> for f32

source§

fn from(small: u8) -> f32

Converts u8 to f32 losslessly.

1.0.0 · source§

impl FromStr for f32

source§

fn from_str(src: &str) -> Result<f32, 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

The associated error which can be returned from parsing.
1.0.0 · source§

impl LowerExp for f32

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
1.0.0 · source§

impl Mul<&f32> for f32

§

type Output = <f32 as Mul<f32>>::Output

The resulting type after applying the * operator.
source§

fn mul(self, other: &f32) -> <f32 as Mul<f32>>::Output

Performs the * operation. Read more
1.0.0 · source§

impl Mul<f32> for f32

§

type Output = f32

The resulting type after applying the * operator.
source§

fn mul(self, other: f32) -> f32

Performs the * operation. Read more
1.22.0 · source§

impl MulAssign<&f32> for f32

source§

fn mul_assign(&mut self, other: &f32)

Performs the *= operation. Read more
1.8.0 · source§

impl MulAssign<f32> for f32

source§

fn mul_assign(&mut self, other: f32)

Performs the *= operation. Read more
1.0.0 · source§

impl Neg for f32

§

type Output = f32

The resulting type after applying the - operator.
source§

fn neg(self) -> f32

Performs the unary - operation. Read more
1.0.0 · source§

impl PartialEq<f32> for f32

source§

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

This method tests for self and other values to be equal, and is used by ==.
source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.0.0 · source§

impl PartialOrd<f32> for f32

source§

fn partial_cmp(&self, other: &f32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.12.0 · source§

impl<'a> Product<&'a f32> for f32

source§

fn product<I>(iter: I) -> f32where I: Iterator<Item = &'a f32>,

Method which takes an iterator and generates Self from the elements by multiplying the items.
1.12.0 · source§

impl Product<f32> for f32

source§

fn product<I>(iter: I) -> f32where I: Iterator<Item = f32>,

Method which takes an iterator and generates Self from the elements by multiplying the items.
1.0.0 · source§

impl Rem<&f32> for f32

§

type Output = <f32 as Rem<f32>>::Output

The resulting type after applying the % operator.
source§

fn rem(self, other: &f32) -> <f32 as Rem<f32>>::Output

Performs the % operation. Read more
1.0.0 · source§

impl Rem<f32> for f32

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);
§

type Output = f32

The resulting type after applying the % operator.
source§

fn rem(self, other: f32) -> f32

Performs the % operation. Read more
1.22.0 · source§

impl RemAssign<&f32> for f32

source§

fn rem_assign(&mut self, other: &f32)

Performs the %= operation. Read more
1.8.0 · source§

impl RemAssign<f32> for f32

source§

fn rem_assign(&mut self, other: f32)

Performs the %= operation. Read more
source§

impl SimdElement for f32

§

type Mask = i32

🔬This is a nightly-only experimental API. (portable_simd #86656)
The mask element type corresponding to this element type.
1.0.0 · source§

impl Sub<&f32> for f32

§

type Output = <f32 as Sub<f32>>::Output

The resulting type after applying the - operator.
source§

fn sub(self, other: &f32) -> <f32 as Sub<f32>>::Output

Performs the - operation. Read more
1.0.0 · source§

impl Sub<f32> for f32

§

type Output = f32

The resulting type after applying the - operator.
source§

fn sub(self, other: f32) -> f32

Performs the - operation. Read more
1.22.0 · source§

impl SubAssign<&f32> for f32

source§

fn sub_assign(&mut self, other: &f32)

Performs the -= operation. Read more
1.8.0 · source§

impl SubAssign<f32> for f32

source§

fn sub_assign(&mut self, other: f32)

Performs the -= operation. Read more
1.12.0 · source§

impl<'a> Sum<&'a f32> for f32

source§

fn sum<I>(iter: I) -> f32where I: Iterator<Item = &'a f32>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
1.12.0 · source§

impl Sum<f32> for f32

source§

fn sum<I>(iter: I) -> f32where I: Iterator<Item = f32>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
1.0.0 · source§

impl UpperExp for f32

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.
source§

impl Value for f32

source§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
1.0.0 · source§

impl Copy for f32

source§

impl FloatToInt<i128> for f32

source§

impl FloatToInt<i16> for f32

source§

impl FloatToInt<i32> for f32

source§

impl FloatToInt<i64> for f32

source§

impl FloatToInt<i8> for f32

source§

impl FloatToInt<isize> for f32

source§

impl FloatToInt<u128> for f32

source§

impl FloatToInt<u16> for f32

source§

impl FloatToInt<u32> for f32

source§

impl FloatToInt<u64> for f32

source§

impl FloatToInt<u8> for f32

source§

impl FloatToInt<usize> for f32

source§

impl SimdCast for f32