Trait fixed::traits::FromFixed[][src]

pub trait FromFixed {
    fn from_fixed<F: Fixed>(src: F) -> Self;
fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>
    where
        Self: Sized
;
fn saturating_from_fixed<F: Fixed>(src: F) -> Self;
fn wrapping_from_fixed<F: Fixed>(src: F) -> Self;
fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)
    where
        Self: Sized
; fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self
    where
        Self: Sized
, { ... } }
Expand description

This trait provides checked conversions from fixed-point numbers.

This trait is implemented for conversions between integer primitives, floating-point primitives and fixed-point numbers.

Examples

use fixed::traits::FromFixed;
use fixed::types::U8F8;
// 0x87.65
let f = U8F8::from_bits(0x8765);
assert_eq!(f32::from_fixed(f), f32::from(0x8765u16) / 256.0);
assert_eq!(i32::checked_from_fixed(f), Some(0x87));
assert_eq!(u8::saturating_from_fixed(f), 0x87);
// no fit
assert_eq!(i8::checked_from_fixed(f), None);
assert_eq!(i8::saturating_from_fixed(f), i8::MAX);
assert_eq!(i8::wrapping_from_fixed(f), 0x87u8 as i8);
assert_eq!(i8::overflowing_from_fixed(f), (0x87u8 as i8, true));

Required methods

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Expand description

Converts from a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self> where
    Self: Sized
[src]

Expand description

Converts from a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Expand description

Converts from a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Expand description

Converts from a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool) where
    Self: Sized
[src]

Expand description

Converts from a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

Loading content...

Provided methods

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self where
    Self: Sized
[src]

Expand description

Converts from a fixed-point number, panicking if the value does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

Loading content...

Implementations on Foreign Types

impl FromFixed for i8[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for i16[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for i32[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for i64[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for i128[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for isize[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for u8[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for u16[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for u32[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for u64[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for u128[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for usize[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer.

Any fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to an integer if it fits, otherwise returns None.

Any fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, saturating if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, wrapping if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to an integer.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to an integer, panicking if it does not fit.

Any fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for f16[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number.

Rounding is to the nearest, with ties rounded to even.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to a floating-point number if it fits, otherwise returns None.

Rounding is to the nearest, with ties rounded to even.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, saturating if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, wrapping if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to a floating-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Rounding is to the nearest, with ties rounded to even.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, panicking if it does not fit.

Rounding is to the nearest, with ties rounded to even.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for bf16[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number.

Rounding is to the nearest, with ties rounded to even.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to a floating-point number if it fits, otherwise returns None.

Rounding is to the nearest, with ties rounded to even.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, saturating if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, wrapping if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to a floating-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Rounding is to the nearest, with ties rounded to even.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, panicking if it does not fit.

Rounding is to the nearest, with ties rounded to even.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for f32[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number.

Rounding is to the nearest, with ties rounded to even.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to a floating-point number if it fits, otherwise returns None.

Rounding is to the nearest, with ties rounded to even.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, saturating if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, wrapping if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to a floating-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Rounding is to the nearest, with ties rounded to even.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, panicking if it does not fit.

Rounding is to the nearest, with ties rounded to even.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl FromFixed for f64[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number.

Rounding is to the nearest, with ties rounded to even.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to a floating-point number if it fits, otherwise returns None.

Rounding is to the nearest, with ties rounded to even.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, saturating if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, wrapping if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to a floating-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Rounding is to the nearest, with ties rounded to even.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, panicking if it does not fit.

Rounding is to the nearest, with ties rounded to even.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

Loading content...

Implementors

impl FromFixed for F128Bits[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number.

Rounding is to the nearest, with ties rounded to even.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number to a floating-point number if it fits, otherwise returns None.

Rounding is to the nearest, with ties rounded to even.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, saturating if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, wrapping if it does not fit.

Rounding is to the nearest, with ties rounded to even.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number to a floating-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Rounding is to the nearest, with ties rounded to even.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number to a floating-point number, panicking if it does not fit.

Rounding is to the nearest, with ties rounded to even.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU8> FromFixed for FixedI8<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU8> FromFixed for FixedU8<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU16> FromFixed for FixedI16<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU16> FromFixed for FixedU16<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU32> FromFixed for FixedI32<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU32> FromFixed for FixedU32<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU64> FromFixed for FixedI64<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU64> FromFixed for FixedU64<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU128> FromFixed for FixedI128<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

impl<Frac: LeEqU128> FromFixed for FixedU128<Frac>[src]

fn from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

When debug assertions are enabled, panics if the value does not fit. When debug assertions are not enabled, the wrapped value can be returned, but it is not considered a breaking change if in the future it panics; if wrapping is required use wrapping_from_fixed instead.

fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>[src]

Converts a fixed-point number if it fits, otherwise returns None.

Any extra fractional bits are discarded, which rounds towards −∞.

fn saturating_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, saturating if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn wrapping_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, wrapping if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)[src]

Converts a fixed-point number.

Returns a tuple of the value and a bool indicating whether an overflow has occurred. On overflow, the wrapped value is returned.

Any extra fractional bits are discarded, which rounds towards −∞.

fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self[src]

Converts a fixed-point number, panicking if it does not fit.

Any extra fractional bits are discarded, which rounds towards −∞.

Panics

Panics if the value does not fit, even when debug assertions are not enabled.

Loading content...