Trait fixed::traits::ToFixed [−][src]
pub trait ToFixed { fn to_fixed<F: Fixed>(self) -> F; fn checked_to_fixed<F: Fixed>(self) -> Option<F>; fn saturating_to_fixed<F: Fixed>(self) -> F; fn wrapping_to_fixed<F: Fixed>(self) -> F; fn overflowing_to_fixed<F: Fixed>(self) -> (F, bool); fn unwrapped_to_fixed<F: Fixed>(self) -> F
where
Self: Sized, { ... } }
Expand description
This trait provides checked conversions to fixed-point numbers.
This trait is implemented for conversions between integer primitives, floating-point primitives and fixed-point numbers.
Examples
use fixed::traits::ToFixed; use fixed::types::{U8F8, U16F16}; let f: U8F8 = 13.5f32.to_fixed(); assert_eq!(f, U8F8::from_bits((13 << 8) | (1 << 7))); // 0x1234.5678 is too large and can be wrapped to 0x34.56 let too_large = U16F16::from_bits(0x1234_5678); let checked: Option<U8F8> = too_large.checked_to_num(); assert_eq!(checked, None); let saturating: U8F8 = too_large.saturating_to_num(); assert_eq!(saturating, U8F8::MAX); let wrapping: U8F8 = too_large.wrapping_to_num(); assert_eq!(wrapping, U8F8::from_bits(0x3456)); let overflowing: (U8F8, bool) = too_large.overflowing_to_num(); assert_eq!(overflowing, (U8F8::from_bits(0x3456), true));
Required methods
fn to_fixed<F: Fixed>(self) -> F
[src]
Expand description
Converts to a fixed-point number.
Any extra fractional bits are discarded, which rounds towards −∞.
Panics
Panics if self
is a floating-point number that is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
Expand description
Converts to a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
Expand description
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
Expand description
fn overflowing_to_fixed<F: Fixed>(self) -> (F, bool)
[src]
Expand description
Converts to a fixed-point number.
Returns a tuple of the fixed-point number 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 −∞.
Panics
Panics if self
is a floating-point number that is not finite.
Provided methods
fn unwrapped_to_fixed<F: Fixed>(self) -> F where
Self: Sized,
[src]
Self: Sized,
Implementations on Foreign Types
impl ToFixed for bool
[src]
impl ToFixed for bool
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a bool
to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Convert a bool
to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a bool
to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]impl ToFixed for i8
[src]
impl ToFixed for i8
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for i16
[src]
impl ToFixed for i16
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for i32
[src]
impl ToFixed for i32
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for i64
[src]
impl ToFixed for i64
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for i128
[src]
impl ToFixed for i128
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for isize
[src]
impl ToFixed for isize
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for u8
[src]
impl ToFixed for u8
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for u16
[src]
impl ToFixed for u16
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for u32
[src]
impl ToFixed for u32
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for u64
[src]
impl ToFixed for u64
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for u128
[src]
impl ToFixed for u128
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for usize
[src]
impl ToFixed for usize
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number.
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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts an integer to a fixed-point number if it fits, otherwise returns None
.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, saturating if it does not fit.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, wrapping if it does not fit.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Converts an integer to a fixed-point number, panicking if it does not fit.
Panics
Panics if the value does not fit, even when debug assertions are not enabled.
impl ToFixed for f16
[src]
impl ToFixed for f16
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a floating-point number to a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
Panics
Panics if self
is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a floating-point number to a fixed-point
number if it fits, otherwise returns None
.
Rounding is to the nearest, with ties rounded to even.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]impl ToFixed for bf16
[src]
impl ToFixed for bf16
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a floating-point number to a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
Panics
Panics if self
is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a floating-point number to a fixed-point
number if it fits, otherwise returns None
.
Rounding is to the nearest, with ties rounded to even.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]impl ToFixed for f32
[src]
impl ToFixed for f32
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a floating-point number to a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
Panics
Panics if self
is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a floating-point number to a fixed-point
number if it fits, otherwise returns None
.
Rounding is to the nearest, with ties rounded to even.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]impl ToFixed for f64
[src]
impl ToFixed for f64
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a floating-point number to a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
Panics
Panics if self
is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a floating-point number to a fixed-point
number if it fits, otherwise returns None
.
Rounding is to the nearest, with ties rounded to even.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]Implementors
impl ToFixed for F128Bits
[src]
impl ToFixed for F128Bits
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[src]Converts a floating-point number to a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
Panics
Panics if self
is not finite.
When debug assertions are enabled, also 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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a floating-point number to a fixed-point
number if it fits, otherwise returns None
.
Rounding is to the nearest, with ties rounded to even.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]impl<Frac: LeEqU8> ToFixed for FixedI8<Frac>
[src]
impl<Frac: LeEqU8> ToFixed for FixedI8<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedU8<Frac>
[src]
impl<Frac: LeEqU8> ToFixed for FixedU8<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedI16<Frac>
[src]
impl<Frac: LeEqU16> ToFixed for FixedI16<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedU16<Frac>
[src]
impl<Frac: LeEqU16> ToFixed for FixedU16<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedI32<Frac>
[src]
impl<Frac: LeEqU32> ToFixed for FixedI32<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedU32<Frac>
[src]
impl<Frac: LeEqU32> ToFixed for FixedU32<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedI64<Frac>
[src]
impl<Frac: LeEqU64> ToFixed for FixedI64<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedU64<Frac>
[src]
impl<Frac: LeEqU64> ToFixed for FixedU64<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedI128<Frac>
[src]
impl<Frac: LeEqU128> ToFixed for FixedI128<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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> ToFixed for FixedU128<Frac>
[src]
impl<Frac: LeEqU128> ToFixed for FixedU128<Frac>
[src]fn to_fixed<F: Fixed>(self) -> F
[src]
fn to_fixed<F: Fixed>(self) -> F
[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_to_fixed
instead.
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
[src]Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]
fn saturating_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]
fn wrapping_to_fixed<F: Fixed>(self) -> F
[src]Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[src]
fn unwrapped_to_fixed<F: Fixed>(self) -> F
[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.