pub trait RoundingFrom<T>: Sized {
    // Required method
    fn rounding_from(value: T, rm: RoundingMode) -> (Self, Ordering);
}
Expand description

Converts a value from one type to another, where the conversion is made according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

Required Methods§

source

fn rounding_from(value: T, rm: RoundingMode) -> (Self, Ordering)

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl RoundingFrom<f32> for i8

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (i8, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for i16

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (i16, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for i32

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (i32, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for i64

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (i64, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for i128

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (i128, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for isize

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (isize, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for u8

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (u8, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for u16

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (u16, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for u32

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (u32, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for u64

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (u64, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for u128

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (u128, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f32> for usize

source§

fn rounding_from(value: f32, rm: RoundingMode) -> (usize, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for i8

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (i8, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for i16

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (i16, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for i32

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (i32, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for i64

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (i64, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for i128

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (i128, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for isize

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (isize, Ordering)

Converts a value of a floating point type to a value of a signed type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned. If the float is greater than the maximum representable signed value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable signed value, the maximum signed value is returned. If the float is smaller than the minimum representable signed value, the minimum signed value is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the signed type and rm is Ceiling or Up.
  • If value is smaller than the minimum value of the signed type and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for u8

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (u8, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for u16

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (u16, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for u32

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (u32, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for u64

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (u64, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for u128

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (u128, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<f64> for usize

source§

fn rounding_from(value: f64, rm: RoundingMode) -> (usize, Ordering)

Converts a value of a floating point type to a value of an unsigned type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest number less than or equal to the value is returned. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, the function panics.
  • If the rounding mode is Ceiling, the smallest number greater than or equal to the value is returned. If the float is negative, zero is returned. If the float is greater than the maximum representable unsigned value, the function panics.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the float is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest value is returned. If the value is exactly between two numbers, the even one is selected. If the float is greater than the maximum representable unsigned value, the maximum unsigned value is returned. If the float is negative, zero is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics
  • If value is NaN.
  • If rm is Exact but value is not exactly equal to any value of the unsigned type.
  • If value is greater than the maximum value of the unsigned type and rm is Ceiling or Up.
  • If value is negative and rm is Floor or Up.
§Examples

See here.

source§

impl RoundingFrom<i8> for f32

source§

fn rounding_from(value: i8, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i8> for f64

source§

fn rounding_from(value: i8, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i16> for f32

source§

fn rounding_from(value: i16, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i16> for f64

source§

fn rounding_from(value: i16, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i32> for f32

source§

fn rounding_from(value: i32, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i32> for f64

source§

fn rounding_from(value: i32, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i64> for f32

source§

fn rounding_from(value: i64, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i64> for f64

source§

fn rounding_from(value: i64, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i128> for f32

source§

fn rounding_from(value: i128, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<i128> for f64

source§

fn rounding_from(value: i128, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<isize> for f32

source§

fn rounding_from(value: isize, rm: RoundingMode) -> (f32, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<isize> for f64

source§

fn rounding_from(value: isize, rm: RoundingMode) -> (f64, Ordering)

Converts a value of a signed type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Down, then the rounding proceeds as with Floor if the value is non-negative and as with Ceiling if the value is negative.
  • If the rounding mode is Up, then the rounding proceeds as with Ceiling if the value is non-negative and as with Floor if the value is negative.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u8> for f32

source§

fn rounding_from(value: u8, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u8> for f64

source§

fn rounding_from(value: u8, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u16> for f32

source§

fn rounding_from(value: u16, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u16> for f64

source§

fn rounding_from(value: u16, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u32> for f32

source§

fn rounding_from(value: u32, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u32> for f64

source§

fn rounding_from(value: u32, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u64> for f32

source§

fn rounding_from(value: u64, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u64> for f64

source§

fn rounding_from(value: u64, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u128> for f32

source§

fn rounding_from(value: u128, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<u128> for f64

source§

fn rounding_from(value: u128, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<usize> for f32

source§

fn rounding_from(value: usize, rm: RoundingMode) -> (f32, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

source§

impl RoundingFrom<usize> for f64

source§

fn rounding_from(value: usize, rm: RoundingMode) -> (f64, Ordering)

Converts a value of an unsigned type to a value of a floating point type according to a specified RoundingMode. An Ordering is also returned, indicating whether the returned value is less than, equal to, or greater than the original value.

  • If the rounding mode is Floor or Down, the largest float less than or equal to the value is returned.
  • If the rounding mode is Ceiling or Up, the smallest float greater than or equal to the value is returned.
  • If the rounding mode is Nearest, then the nearest float is returned. If the value is exactly between two floats, the float with the zero least-significant bit in its representation is selected. If the value is larger than the maximum finite float (which can only happen when converting a u128 to an f32), the maximum finite float is returned.
§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if rm is Exact but value is not exactly equal to any value of the primitive float type.

§Examples

See here.

Implementors§