pub struct FixedU32<Frac> { /* private fields */ }
Expand description
A 32-bit unsigned number with Frac
fractional bits.
The number has 32 bits, of which f = Frac
are
fractional bits and 32 − f are integer bits.
The value x can lie in the range 0 ≤ x < 232/2f. The difference between successive
numbers is constant throughout the range: Δ = 1/2f.
For FixedU32<U0>
, f = 0 and
Δ = 1, and the fixed-point number behaves like a u32
with the value lying in the range 0 ≤ x < 232. For FixedU32<U32>
,
f = 32 and
Δ = 1/232, and the value lies in the
range 0 ≤ x < 1.
Frac
is an Unsigned
as provided by the typenum crate; the plan is to
to have a major version 2 where Frac
is replaced by FRAC
of type i32
when the Rust compiler’s generic_const_exprs
feature is ready and stabilized.
An alpha version is already available.
FixedU32<Frac>
has the same size, alignment and ABI as
u32
; it is #[repr(transparent)]
with
u32
as the only non-zero-sized field.
§Examples
use fixed::{types::extra::U3, FixedU32};
let eleven = FixedU32::<U3>::from_num(11);
assert_eq!(eleven, FixedU32::<U3>::from_bits(11 << 3));
assert_eq!(eleven, 11);
assert_eq!(eleven.to_string(), "11");
let two_point_75 = eleven / 4;
assert_eq!(two_point_75, FixedU32::<U3>::from_bits(11 << 1));
assert_eq!(two_point_75, 2.75);
assert_eq!(two_point_75.to_string(), "2.8");
Implementations§
source§impl<Frac> FixedU32<Frac>
impl<Frac> FixedU32<Frac>
The implementation of items in this block is independent
of the number of fractional bits Frac
.
sourcepub const ZERO: FixedU32<Frac> = _
pub const ZERO: FixedU32<Frac> = _
Zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO, Fix::from_bits(0));
sourcepub const DELTA: FixedU32<Frac> = _
pub const DELTA: FixedU32<Frac> = _
The difference between any two successive representable numbers, Δ.
If the number has f = Frac
fractional bits, then
Δ = 1/2f.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::DELTA, Fix::from_bits(1));
// binary 0.0001 is decimal 0.0625
assert_eq!(Fix::DELTA, 0.0625);
sourcepub const MIN: FixedU32<Frac> = _
pub const MIN: FixedU32<Frac> = _
The smallest value that can be represented.
The minimum of unsigned numbers is 0.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::MIN, Fix::from_bits(u32::MIN));
sourcepub const MAX: FixedU32<Frac> = _
pub const MAX: FixedU32<Frac> = _
The largest value that can be represented.
If the number has f = Frac
fractional bits, then the maximum is
(232 − 1)/2f.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::MAX, Fix::from_bits(u32::MAX));
sourcepub const fn from_bits(bits: u32) -> FixedU32<Frac>
pub const fn from_bits(bits: u32) -> FixedU32<Frac>
Creates a fixed-point number that has a bitwise representation identical to the given integer.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 0010.0000 = 2
assert_eq!(Fix::from_bits(0b10_0000), 2);
sourcepub const fn to_bits(self) -> u32
pub const fn to_bits(self) -> u32
Creates an integer that has a bitwise representation identical to the given fixed-point number.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 2 is 0010.0000
assert_eq!(Fix::from_num(2).to_bits(), 0b10_0000);
sourcepub const fn from_be(f: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn from_be(f: FixedU32<Frac>) -> FixedU32<Frac>
Converts a fixed-point number from big endian to the target’s endianness.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0x1234_5678);
if cfg!(target_endian = "big") {
assert_eq!(Fix::from_be(f), f);
} else {
assert_eq!(Fix::from_be(f), f.swap_bytes());
}
sourcepub const fn from_le(f: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn from_le(f: FixedU32<Frac>) -> FixedU32<Frac>
Converts a fixed-point number from little endian to the target’s endianness.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0x1234_5678);
if cfg!(target_endian = "little") {
assert_eq!(Fix::from_le(f), f);
} else {
assert_eq!(Fix::from_le(f), f.swap_bytes());
}
sourcepub const fn to_be(self) -> FixedU32<Frac>
pub const fn to_be(self) -> FixedU32<Frac>
Converts self
to big endian from the target’s endianness.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0x1234_5678);
if cfg!(target_endian = "big") {
assert_eq!(f.to_be(), f);
} else {
assert_eq!(f.to_be(), f.swap_bytes());
}
sourcepub const fn to_le(self) -> FixedU32<Frac>
pub const fn to_le(self) -> FixedU32<Frac>
Converts self
to little endian from the target’s endianness.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0x1234_5678);
if cfg!(target_endian = "little") {
assert_eq!(f.to_le(), f);
} else {
assert_eq!(f.to_le(), f.swap_bytes());
}
sourcepub const fn swap_bytes(self) -> FixedU32<Frac>
pub const fn swap_bytes(self) -> FixedU32<Frac>
Reverses the byte order of the fixed-point number.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0x1234_5678);
let swapped = Fix::from_bits(0x7856_3412);
assert_eq!(f.swap_bytes(), swapped);
sourcepub const fn from_be_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
pub const fn from_be_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
Creates a fixed-point number from its representation as a byte array in big endian.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_be_bytes([0x12, 0x34, 0x56, 0x78]),
Fix::from_bits(0x1234_5678)
);
sourcepub const fn from_le_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
pub const fn from_le_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
Creates a fixed-point number from its representation as a byte array in little endian.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_le_bytes([0x78, 0x56, 0x34, 0x12]),
Fix::from_bits(0x1234_5678)
);
sourcepub const fn from_ne_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
pub const fn from_ne_bytes(bytes: [u8; 4]) -> FixedU32<Frac>
Creates a fixed-point number from its representation as a byte array in native endian.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
if cfg!(target_endian = "big") {
Fix::from_ne_bytes([0x12, 0x34, 0x56, 0x78])
} else {
Fix::from_ne_bytes([0x78, 0x56, 0x34, 0x12])
},
Fix::from_bits(0x1234_5678)
);
sourcepub const fn to_be_bytes(self) -> [u8; 4]
pub const fn to_be_bytes(self) -> [u8; 4]
Returns the memory representation of this fixed-point number as a byte array in big-endian byte order.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let val = Fix::from_bits(0x1234_5678);
assert_eq!(
val.to_be_bytes(),
[0x12, 0x34, 0x56, 0x78]
);
sourcepub const fn to_le_bytes(self) -> [u8; 4]
pub const fn to_le_bytes(self) -> [u8; 4]
Returns the memory representation of this fixed-point number as a byte array in little-endian byte order.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let val = Fix::from_bits(0x1234_5678);
assert_eq!(
val.to_le_bytes(),
[0x78, 0x56, 0x34, 0x12]
);
sourcepub const fn to_ne_bytes(self) -> [u8; 4]
pub const fn to_ne_bytes(self) -> [u8; 4]
Returns the memory representation of this fixed-point number as a byte array in native byte order.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let val = Fix::from_bits(0x1234_5678);
assert_eq!(
val.to_ne_bytes(),
if cfg!(target_endian = "big") {
[0x12, 0x34, 0x56, 0x78]
} else {
[0x78, 0x56, 0x34, 0x12]
}
);
sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Returns the number of ones in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0b11_0010);
assert_eq!(f.count_ones(), 3);
sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Returns the number of zeros in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(!0b11_0010);
assert_eq!(f.count_zeros(), 3);
sourcepub const fn leading_ones(self) -> u32
pub const fn leading_ones(self) -> u32
Returns the number of leading ones in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let all_ones = !Fix::ZERO;
let f = all_ones - Fix::from_bits(0b10_0000);
assert_eq!(f.leading_ones(), 32 - 6);
sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Returns the number of leading zeros in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0b10_0000);
assert_eq!(f.leading_zeros(), 32 - 6);
sourcepub const fn trailing_ones(self) -> u32
pub const fn trailing_ones(self) -> u32
Returns the number of trailing ones in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0b101_1111);
assert_eq!(f.trailing_ones(), 5);
sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Returns the number of trailing zeros in the binary representation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let f = Fix::from_bits(0b10_0000);
assert_eq!(f.trailing_zeros(), 5);
sourcepub const fn significant_bits(self) -> u32
pub const fn significant_bits(self) -> u32
Returns the number of bits required to represent the value.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(0).significant_bits(), 0); // “____.____”
assert_eq!(Fix::from_num(0.0625).significant_bits(), 1); // “____.___1”
assert_eq!(Fix::from_num(1).significant_bits(), 5); // “___1.0000”
assert_eq!(Fix::from_num(3).significant_bits(), 6); // “__11.0000”
sourcepub const fn reverse_bits(self) -> FixedU32<Frac>
pub const fn reverse_bits(self) -> FixedU32<Frac>
Reverses the order of the bits of the fixed-point number.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let bits = 0x1234_5678_u32;
let rev_bits = bits.reverse_bits();
assert_eq!(Fix::from_bits(bits).reverse_bits(), Fix::from_bits(rev_bits));
sourcepub const fn rotate_left(self, n: u32) -> FixedU32<Frac>
pub const fn rotate_left(self, n: u32) -> FixedU32<Frac>
Shifts to the left by n
bits, wrapping the
truncated bits to the right end.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let bits: u32 = (0b111 << (32 - 3)) | 0b1010;
let rot = 0b1010111;
assert_eq!(bits.rotate_left(3), rot);
assert_eq!(Fix::from_bits(bits).rotate_left(3), Fix::from_bits(rot));
sourcepub const fn rotate_right(self, n: u32) -> FixedU32<Frac>
pub const fn rotate_right(self, n: u32) -> FixedU32<Frac>
Shifts to the right by n
bits, wrapping the
truncated bits to the left end.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let bits: u32 = 0b1010111;
let rot = (0b111 << (32 - 3)) | 0b1010;
assert_eq!(bits.rotate_right(3), rot);
assert_eq!(Fix::from_bits(bits).rotate_right(3), Fix::from_bits(rot));
sourcepub const fn is_power_of_two(self) -> bool
pub const fn is_power_of_two(self) -> bool
Returns true
if the fixed-point number is
2k for some integer k.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 3/8 is 0.0110
let three_eights = Fix::from_bits(0b0110);
// 1/2 is 0.1000
let half = Fix::from_bits(0b1000);
assert!(!three_eights.is_power_of_two());
assert!(half.is_power_of_two());
sourcepub const fn wide_mul<RhsFrac>(
self,
rhs: FixedU32<RhsFrac>,
) -> FixedU64<Sum<Frac, RhsFrac>>where
Frac: Add<RhsFrac>,
pub const fn wide_mul<RhsFrac>(
self,
rhs: FixedU32<RhsFrac>,
) -> FixedU64<Sum<Frac, RhsFrac>>where
Frac: Add<RhsFrac>,
Multiplies two fixed-point numbers and returns a wider type to retain all precision.
If self
has f fractional bits and 32 − f
integer bits, and rhs
has g fractional bits and 32 − g integer bits, then the returned fixed-point number will
have f + g fractional bits and 64 − f − g integer bits.
§Examples
use fixed::{
types::extra::{U2, U4},
FixedU32,
};
// decimal: 1.25 × 1.0625 = 1.328_125
// binary: 1.01 × 1.0001 = 1.010101
let a = FixedU32::<U2>::from_num(1.25);
let b = FixedU32::<U4>::from_num(1.0625);
assert_eq!(a.wide_mul(b), 1.328_125);
sourcepub const fn wide_mul_signed<RhsFrac>(
self,
rhs: FixedI32<RhsFrac>,
) -> FixedI64<Sum<Frac, RhsFrac>>where
Frac: Add<RhsFrac>,
pub const fn wide_mul_signed<RhsFrac>(
self,
rhs: FixedI32<RhsFrac>,
) -> FixedI64<Sum<Frac, RhsFrac>>where
Frac: Add<RhsFrac>,
Multiplies a signed fixed-point number and returns a wider signed type to retain all precision.
If self
has f fractional bits and
32 − f
integer bits, and rhs
has g fractional bits and
32 − g
integer bits, then the returned fixed-point number will
have f + g fractional bits and
64 − f − g
integer bits.
§Examples
use fixed::{
types::extra::{U2, U4},
FixedI32, FixedU32,
};
// decimal: 1.25 × -1.0625 = -1.328_125
// binary: 1.01 × -1.0001 = -1.010101
let a = FixedU32::<U2>::from_num(1.25);
let b = FixedI32::<U4>::from_num(-1.0625);
assert_eq!(a.wide_mul_signed(b), -1.328_125);
sourcepub const fn wide_div<RhsFrac>(
self,
rhs: FixedU32<RhsFrac>,
) -> FixedU64<Diff<Sum<U32, Frac>, RhsFrac>>
pub const fn wide_div<RhsFrac>( self, rhs: FixedU32<RhsFrac>, ) -> FixedU64<Diff<Sum<U32, Frac>, RhsFrac>>
Divides two fixed-point numbers and returns a wider type to retain more precision.
If self
has f fractional bits
and 32 − f integer bits, and rhs
has
g fractional bits and 32 − g integer
bits, then the returned fixed-point number will
have 32 + f − g fractional
bits and 32 − f + g integer
bits.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{
types::extra::{U3, U5, U30},
FixedU32, FixedU64,
};
// decimal: 4.625 / 0.03125 = 148
// binary: 100.101 / 0.00001 = 10010100
let a = FixedU32::<U3>::from_num(4.625);
let b = FixedU32::<U5>::from_num(0.03125);
let ans: FixedU64<U30> = a.wide_div(b);
assert_eq!(ans, 148);
sourcepub const fn wide_sdiv_signed<RhsFrac>(
self,
rhs: FixedI32<RhsFrac>,
) -> FixedI64<Diff<Sum<U31, Frac>, RhsFrac>>
pub const fn wide_sdiv_signed<RhsFrac>( self, rhs: FixedI32<RhsFrac>, ) -> FixedI64<Diff<Sum<U31, Frac>, RhsFrac>>
Divides by a signed fixed-point number and returns a wider signed type to retain more precision.
If self
has f fractional bits and
32 − f
integer bits, and rhs
has g fractional bits and
32 − g
integer bits, then the returned fixed-point number will have
31 + f − g
fractional bits and
33 − f + g
integer bits.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{
types::extra::{U4, U5, U30},
FixedU32, FixedI32, FixedI64,
};
// decimal: 4.625 / -0.03125 = -148
// binary: 100.101 / -0.00001 = -10010100
let a = FixedU32::<U4>::from_num(4.625);
let b = FixedI32::<U5>::from_num(-0.03125);
let ans: FixedI64<U30> = a.wide_sdiv_signed(b);
assert_eq!(ans, -148);
sourcepub const fn mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> FixedU32<Frac>
Multiply and add. Returns self
× mul
+ add
.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Panics
When debug assertions are enabled, this method panics if the result
overflows. 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_mul_add
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).mul_add(Fix::from_num(0.5), Fix::from_num(3)),
Fix::from_num(5)
);
sourcepub const fn rem_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn rem_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
sourcepub const fn dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Returns the distance from self
to other
.
The distance is the absolute value of the difference.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE.dist(Fix::from_num(5)), Fix::from_num(4));
sourcepub const fn abs_diff(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn abs_diff(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Returns the absolute value of the difference between self
and other
.
This method is the same as dist
for unsigned fixed-point numbers.
sourcepub const fn mean(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn mean(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Returns the mean of self
and other
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).mean(Fix::from_num(4)), Fix::from_num(3.5));
sourcepub const fn hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Compute the hypotenuse of a right triange.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Panics
When debug assertions are enabled, this method panics if the result overflows.
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_hypot
instead.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(Fix::from_num(3).hypot(Fix::from_num(4)), Fix::from_num(5));
sourcepub const fn next_multiple_of(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn next_multiple_of(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Returns the smallest multiple of other
that is ≥ self
.
§Panics
Panics if other
is zero.
When debug assertions are enabled, this method also panics if the result
overflows. 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_next_multiple_of
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).next_multiple_of(Fix::from_num(1.5)),
Fix::from_num(4.5)
);
sourcepub const fn inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> FixedU32<RetFrac>
pub const fn inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> FixedU32<RetFrac>
Inverse linear interpolation between start
and end
.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Returns
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Panics
Panics when start
= end
.
When debug assertions are enabled, this method also panics if the result
overflows. 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_inv_lerp
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let start = Fix::from_num(2);
let end = Fix::from_num(3.5);
assert_eq!(Fix::from_num(2).inv_lerp::<U4>(start, end), 0);
assert_eq!(Fix::from_num(2.75).inv_lerp::<U4>(start, end), 0.5);
assert_eq!(Fix::from_num(3.5).inv_lerp::<U4>(start, end), 1);
assert_eq!(Fix::from_num(5).inv_lerp::<U4>(start, end), 2);
sourcepub const fn highest_one(self) -> FixedU32<Frac>
pub const fn highest_one(self) -> FixedU32<Frac>
Returns the highest one in the binary
representation, or zero if self
is zero.
If self
> 0, the highest one is equal to the largest power of two
that is ≤ self
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_bits(0b11_0010).highest_one(), Fix::from_bits(0b10_0000));
assert_eq!(Fix::from_num(0.3).highest_one(), Fix::from_num(0.25));
assert_eq!(Fix::from_num(4).highest_one(), Fix::from_num(4));
assert_eq!(Fix::from_num(6.5).highest_one(), Fix::from_num(4));
assert_eq!(Fix::ZERO.highest_one(), Fix::ZERO);
sourcepub const fn next_power_of_two(self) -> FixedU32<Frac>
pub const fn next_power_of_two(self) -> FixedU32<Frac>
Returns the smallest power of two that is ≥ self
.
§Panics
When debug assertions are enabled, panics if the next power of two is
too large to represent. When debug assertions are not enabled, zero
can be returned, but it is not considered a breaking change if in the
future it panics; if this is not desirable use
checked_next_power_of_two
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_bits(0b11_0010).next_power_of_two(), Fix::from_bits(0b100_0000));
assert_eq!(Fix::from_num(0.3).next_power_of_two(), Fix::from_num(0.5));
assert_eq!(Fix::from_num(4).next_power_of_two(), Fix::from_num(4));
assert_eq!(Fix::from_num(6.5).next_power_of_two(), Fix::from_num(8));
sourcepub const fn add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Addition with a signed fixed-point number.
§Panics
When debug assertions are enabled, this method panics if the
result overflows. 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_add_signed
instead.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).add_signed(IFix::from_num(-3)), 2);
sourcepub const fn sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Subtraction with a signed fixed-point number.
§Panics
When debug assertions are enabled, this method panics if the
result overflows. 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_sub_signed
instead.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).sub_signed(IFix::from_num(-3)), 8);
sourcepub const fn const_not(self) -> FixedU32<Frac>
pub const fn const_not(self) -> FixedU32<Frac>
Bitwise NOT. Usable in constant context.
This is equivalent to the !
operator and
Not::not
, but
can also be used in constant context. Unless required in constant
context, use the operator or trait instead.
§Planned deprecation
This method will be deprecated when the !
operator and the
Not
trait are usable in constant context.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const A: Fix = Fix::from_bits(0x3E);
const NOT_A: Fix = A.const_not();
assert_eq!(NOT_A, !A);
sourcepub const fn const_bitand(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn const_bitand(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Bitwise AND. Usable in constant context.
This is equivalent to the &
operator and
BitAnd::bitand
,
but can also be used in constant context. Unless required in constant
context, use the operator or trait instead.
§Planned deprecation
This method will be deprecated when the &
operator and the
BitAnd
trait are usable in constant context.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const A: Fix = Fix::from_bits(0x3E);
const B: Fix = Fix::from_bits(0x55);
const A_BITAND_B: Fix = A.const_bitand(B);
assert_eq!(A_BITAND_B, A & B);
sourcepub const fn const_bitor(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn const_bitor(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Bitwise OR. Usable in constant context.
This is equivalent to the |
operator and
BitOr::bitor
,
but can also be used in constant context. Unless required in constant
context, use the operator or trait instead.
§Planned deprecation
This method will be deprecated when the |
operator and the
BitOr
trait are usable in constant context.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const A: Fix = Fix::from_bits(0x3E);
const B: Fix = Fix::from_bits(0x55);
const A_BITOR_B: Fix = A.const_bitor(B);
assert_eq!(A_BITOR_B, A | B);
sourcepub const fn const_bitxor(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn const_bitxor(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Bitwise XOR. Usable in constant context.
This is equivalent to the ^
operator and
BitXor::bitxor
,
but can also be used in constant context. Unless required in constant
context, use the operator or trait instead.
§Planned deprecation
This method will be deprecated when the ^
operator and the
BitXor
trait are usable in constant context.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const A: Fix = Fix::from_bits(0x3E);
const B: Fix = Fix::from_bits(0x55);
const A_BITXOR_B: Fix = A.const_bitxor(B);
assert_eq!(A_BITXOR_B, A ^ B);
sourcepub const fn checked_neg(self) -> Option<FixedU32<Frac>>
pub const fn checked_neg(self) -> Option<FixedU32<Frac>>
sourcepub const fn checked_add(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_add(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
sourcepub const fn checked_sub(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_sub(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
sourcepub const fn checked_rem(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_rem(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
sourcepub const fn checked_mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> Option<FixedU32<Frac>>
Checked multiply and add.
Returns self
× mul
+ add
, or None
on overflow.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).checked_mul_add(Fix::from_num(0.5), Fix::from_num(3)),
Some(Fix::from_num(5))
);
assert_eq!(Fix::MAX.checked_mul_add(Fix::ONE, Fix::ZERO), Some(Fix::MAX));
assert_eq!(Fix::MAX.checked_mul_add(Fix::ONE, Fix::DELTA), None);
sourcepub const fn checked_mul_int(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_mul_int(self, rhs: u32) -> Option<FixedU32<Frac>>
sourcepub const fn checked_div_int(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_div_int(self, rhs: u32) -> Option<FixedU32<Frac>>
sourcepub const fn checked_rem_euclid(
self,
rhs: FixedU32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_rem_euclid( self, rhs: FixedU32<Frac>, ) -> Option<FixedU32<Frac>>
Checked remainder for Euclidean division. Returns the
remainder, or None
if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let num = Fix::from_num(7.5);
assert_eq!(num.checked_rem_euclid(Fix::from_num(2)), Some(Fix::from_num(1.5)));
assert_eq!(num.checked_rem_euclid(Fix::ZERO), None);
sourcepub const fn checked_shl(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_shl(self, rhs: u32) -> Option<FixedU32<Frac>>
sourcepub const fn checked_shr(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_shr(self, rhs: u32) -> Option<FixedU32<Frac>>
sourcepub const fn checked_dist(self, other: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_dist(self, other: FixedU32<Frac>) -> Option<FixedU32<Frac>>
Checked distance. Returns the distance from self
to other
.
The distance is the absolute value of the difference.
Can never overflow for unsigned types.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE.checked_dist(Fix::from_num(5)), Some(Fix::from_num(4)));
assert_eq!(Fix::ZERO.checked_dist(Fix::MAX), Some(Fix::MAX));
sourcepub const fn checked_hypot(
self,
other: FixedU32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_hypot( self, other: FixedU32<Frac>, ) -> Option<FixedU32<Frac>>
Compute the hypotenuse of a right triange, returning None
on overflow.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(
Fix::from_num(3).checked_hypot(Fix::from_num(4)),
Some(Fix::from_num(5))
);
// hypot(8, 15) == 17, which does not fit
assert_eq!(
Fix::from_num(8).checked_hypot(Fix::from_num(15)),
None
);
sourcepub const fn checked_next_multiple_of(
self,
other: FixedU32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_next_multiple_of( self, other: FixedU32<Frac>, ) -> Option<FixedU32<Frac>>
Checked next multiple of other
. Returns the next multiple, or
None
if other
is zero or on overflow.
The next multiple is the smallest multiple of other
that is ≥ self
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).checked_next_multiple_of(Fix::from_num(1.5)),
Some(Fix::from_num(4.5))
);
assert_eq!(Fix::from_num(4).checked_next_multiple_of(Fix::ZERO), None);
assert_eq!(Fix::MAX.checked_next_multiple_of(Fix::from_num(2)), None);
sourcepub const fn checked_inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> Option<FixedU32<RetFrac>>
pub const fn checked_inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> Option<FixedU32<RetFrac>>
Checked inverse linear interpolation between start
and end
.
Returns None
on overflow or when start
= end
.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Returns
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let four = Fix::from_num(4);
assert_eq!(Fix::from_num(3).checked_inv_lerp::<U4>(two, four), Some(Fix::from_num(0.5)));
assert_eq!(Fix::from_num(2).checked_inv_lerp::<U4>(two, two), None);
assert_eq!(Fix::MAX.checked_inv_lerp::<U4>(Fix::ZERO, Fix::from_num(0.5)), None);
sourcepub const fn checked_next_power_of_two(self) -> Option<FixedU32<Frac>>
pub const fn checked_next_power_of_two(self) -> Option<FixedU32<Frac>>
Returns the smallest power of two that is ≥ self
, or
None
if the next power of two is too large to represent.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 3/8 is 0.0110
let three_eights = Fix::from_bits(0b0110);
// 1/2 is 0.1000
let half = Fix::from_bits(0b1000);
assert_eq!(three_eights.checked_next_power_of_two(), Some(half));
assert!(Fix::MAX.checked_next_power_of_two().is_none());
sourcepub const fn checked_add_signed(
self,
rhs: FixedI32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_add_signed( self, rhs: FixedI32<Frac>, ) -> Option<FixedU32<Frac>>
Checked addition with a signed fixed-point number.
Returns the sum, or None
on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(
Fix::from_num(5).checked_add_signed(IFix::from_num(-3)),
Some(Fix::from_num(2))
);
assert_eq!(Fix::from_num(2).checked_add_signed(IFix::from_num(-3)), None);
sourcepub const fn checked_sub_signed(
self,
rhs: FixedI32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_sub_signed( self, rhs: FixedI32<Frac>, ) -> Option<FixedU32<Frac>>
Checked subtraction with a signed fixed-point number.
Returns the difference, or None
on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(
Fix::from_num(5).checked_sub_signed(IFix::from_num(-3)),
Some(Fix::from_num(8))
);
assert_eq!(Fix::from_num(2).checked_sub_signed(IFix::from_num(3)), None);
sourcepub const fn saturating_neg(self) -> FixedU32<Frac>
pub const fn saturating_neg(self) -> FixedU32<Frac>
Saturating negation. Returns the negated value, saturating on overflow.
This method always returns zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.saturating_neg(), Fix::from_num(0));
assert_eq!(Fix::from_num(5).saturating_neg(), Fix::ZERO);
sourcepub const fn saturating_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Saturating addition. Returns the sum, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).saturating_add(Fix::from_num(2)), Fix::from_num(5));
assert_eq!(Fix::MAX.saturating_add(Fix::ONE), Fix::MAX);
sourcepub const fn saturating_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Saturating subtraction. Returns the difference, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(5).saturating_sub(Fix::from_num(3)), Fix::from_num(2));
assert_eq!(Fix::ZERO.saturating_sub(Fix::ONE), Fix::ZERO);
sourcepub const fn saturating_mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn saturating_mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> FixedU32<Frac>
Saturating multiply and add.
Returns self
× mul
+ add
, saturating on overflow.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).saturating_mul_add(Fix::from_num(0.5), Fix::from_num(3)),
Fix::from_num(5)
);
let half_max = Fix::MAX / 2;
assert_eq!(half_max.saturating_mul_add(Fix::from_num(3), half_max), Fix::MAX);
sourcepub const fn saturating_mul_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn saturating_mul_int(self, rhs: u32) -> FixedU32<Frac>
Saturating multiplication by an integer. Returns the product, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).saturating_mul_int(2), Fix::from_num(6));
assert_eq!(Fix::MAX.saturating_mul_int(2), Fix::MAX);
sourcepub const fn saturating_div_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn saturating_div_int(self, rhs: u32) -> FixedU32<Frac>
Saturating division by an integer. Returns the quotient.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.5 is binary 1.1
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).saturating_div_int(2), one_point_5);
sourcepub const fn saturating_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Saturating distance. Returns the distance from self
to other
.
The distance is the absolute value of the difference.
Can never overflow for unsigned types.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE.saturating_dist(Fix::from_num(5)), Fix::from_num(4));
assert_eq!(Fix::ZERO.saturating_dist(Fix::MAX), Fix::MAX);
sourcepub const fn saturating_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Compute the hypotenuse of a right triange, saturating on overflow.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(
Fix::from_num(3).saturating_hypot(Fix::from_num(4)),
Fix::from_num(5)
);
// hypot(8, 15) == 17, which does not fit
assert_eq!(
Fix::from_num(8).saturating_hypot(Fix::from_num(15)),
Fix::MAX
);
sourcepub const fn saturating_next_multiple_of(
self,
other: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn saturating_next_multiple_of( self, other: FixedU32<Frac>, ) -> FixedU32<Frac>
Saturating next multiple of other
.
The next multiple is the smallest multiple of other
that is ≥ self
.
§Panics
Panics if other
is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).saturating_next_multiple_of(Fix::from_num(1.5)),
Fix::from_num(4.5)
);
assert_eq!(Fix::MAX.saturating_next_multiple_of(Fix::from_num(2)), Fix::MAX);
sourcepub const fn saturating_inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> FixedU32<RetFrac>
pub const fn saturating_inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> FixedU32<RetFrac>
Inverse linear interpolation between start
and end
,
saturating on overflow.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Returns
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Panics
Panics when start
= end
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let four = Fix::from_num(4);
assert_eq!(Fix::from_num(3).saturating_inv_lerp::<U4>(two, four), 0.5);
assert_eq!(Fix::MAX.saturating_inv_lerp::<U4>(Fix::ZERO, Fix::from_num(0.5)), Fix::MAX);
assert_eq!(Fix::MAX.saturating_inv_lerp::<U4>(Fix::from_num(0.5), Fix::ZERO), Fix::MIN);
sourcepub const fn saturating_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn saturating_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Saturating addition with a signed fixed-point number. Returns the sum, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).saturating_add_signed(IFix::from_num(-3)), 2);
assert_eq!(Fix::from_num(2).saturating_add_signed(IFix::from_num(-3)), 0);
assert_eq!(Fix::MAX.saturating_add_signed(IFix::MAX), Fix::MAX);
sourcepub const fn saturating_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn saturating_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Saturating subtraction with a signed fixed-point number. Returns the difference, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).saturating_sub_signed(IFix::from_num(-3)), 8);
assert_eq!(Fix::ONE.saturating_sub_signed(IFix::MAX), Fix::ZERO);
assert_eq!(Fix::MAX.saturating_sub_signed(IFix::MIN), Fix::MAX);
sourcepub const fn wrapping_neg(self) -> FixedU32<Frac>
pub const fn wrapping_neg(self) -> FixedU32<Frac>
Wrapping negation. Returns the negated value, wrapping on overflow.
Only zero can be negated without overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.wrapping_neg(), Fix::from_num(0));
assert_eq!(Fix::from_num(5).wrapping_neg(), Fix::wrapping_from_num(-5));
let neg_five_bits = !Fix::from_num(5).to_bits() + 1;
assert_eq!(Fix::from_num(5).wrapping_neg(), Fix::from_bits(neg_five_bits));
sourcepub const fn wrapping_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping addition. Returns the sum, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_minus_delta = Fix::ONE - Fix::DELTA;
assert_eq!(Fix::from_num(3).wrapping_add(Fix::from_num(2)), Fix::from_num(5));
assert_eq!(Fix::MAX.wrapping_add(Fix::ONE), one_minus_delta);
sourcepub const fn wrapping_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping subtraction. Returns the difference, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_minus_delta = Fix::ONE - Fix::DELTA;
assert_eq!(Fix::from_num(5).wrapping_sub(Fix::from_num(3)), Fix::from_num(2));
assert_eq!(Fix::ZERO.wrapping_sub(Fix::ONE), Fix::MAX - one_minus_delta);
sourcepub const fn wrapping_mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn wrapping_mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> FixedU32<Frac>
Wrapping multiply and add.
Returns self
× mul
+ add
, wrapping on overflow.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).wrapping_mul_add(Fix::from_num(0.5), Fix::from_num(3)),
Fix::from_num(5)
);
assert_eq!(Fix::MAX.wrapping_mul_add(Fix::ONE, Fix::from_num(0)), Fix::MAX);
assert_eq!(Fix::MAX.wrapping_mul_add(Fix::ONE, Fix::from_bits(1)), Fix::MIN);
let wrapped = Fix::MAX.wrapping_mul_int(4);
assert_eq!(Fix::MAX.wrapping_mul_add(Fix::from_num(3), Fix::MAX), wrapped);
sourcepub const fn wrapping_mul_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_mul_int(self, rhs: u32) -> FixedU32<Frac>
Wrapping multiplication by an integer. Returns the product, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).wrapping_mul_int(2), Fix::from_num(6));
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.wrapping_mul_int(4), wrapped);
sourcepub const fn wrapping_div_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_div_int(self, rhs: u32) -> FixedU32<Frac>
Wrapping division by an integer. Returns the quotient.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.5 is binary 1.1
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).wrapping_div_int(2), one_point_5);
sourcepub const fn wrapping_shl(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_shl(self, rhs: u32) -> FixedU32<Frac>
Wrapping shift left. Wraps rhs
if rhs
≥ 32,
then shifts and returns the number.
Unlike most other methods which wrap the result, this method (as well as
wrapping_shr
) wraps the input operand rhs
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::ONE / 2).wrapping_shl(3), Fix::from_num(4));
assert_eq!((Fix::ONE / 2).wrapping_shl(3 + 32), Fix::from_num(4));
sourcepub const fn wrapping_shr(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_shr(self, rhs: u32) -> FixedU32<Frac>
Wrapping shift right. Wraps rhs
if rhs
≥ 32,
then shifts and returns the number.
Unlike most other methods which wrap the result, this method (as well as
wrapping_shl
) wraps the input operand rhs
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::from_num(4)).wrapping_shr(3), Fix::ONE / 2);
assert_eq!((Fix::from_num(4)).wrapping_shr(3 + 32), Fix::ONE / 2);
sourcepub const fn wrapping_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping distance. Returns the distance from self
to other
.
The distance is the absolute value of the difference.
Can never overflow for unsigned types.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE.wrapping_dist(Fix::from_num(5)), Fix::from_num(4));
assert_eq!(Fix::ZERO.wrapping_dist(Fix::MAX), Fix::MAX);
sourcepub const fn wrapping_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Compute the hypotenuse of a right triange, wrapping on overflow.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(
Fix::from_num(3).wrapping_hypot(Fix::from_num(4)),
Fix::from_num(5)
);
// hypot(8, 15) == 17, which wraps to 1
assert_eq!(
Fix::from_num(8).wrapping_hypot(Fix::from_num(15)),
Fix::from_num(1)
);
sourcepub const fn wrapping_next_multiple_of(
self,
other: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn wrapping_next_multiple_of( self, other: FixedU32<Frac>, ) -> FixedU32<Frac>
Wrapping next multiple of other
.
The next multiple is the smallest multiple of other
that is ≥ self
.
§Panics
Panics if other
is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).wrapping_next_multiple_of(Fix::from_num(1.5)),
Fix::from_num(4.5)
);
let max_minus_delta = Fix::MAX - Fix::DELTA;
assert_eq!(
Fix::MAX.wrapping_next_multiple_of(max_minus_delta),
max_minus_delta.wrapping_mul_int(2)
);
sourcepub const fn wrapping_inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> FixedU32<RetFrac>
pub const fn wrapping_inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> FixedU32<RetFrac>
Inverse linear interpolation between start
and end
,
wrapping on overflow.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Returns
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Panics
Panics when start
= end
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let four = Fix::from_num(4);
assert_eq!(Fix::from_num(3).wrapping_inv_lerp::<U4>(two, four), 0.5);
assert_eq!(
Fix::MAX.wrapping_inv_lerp::<U4>(Fix::ZERO, Fix::from_num(0.5)),
Fix::MAX.wrapping_mul_int(2)
);
sourcepub const fn wrapping_next_power_of_two(self) -> FixedU32<Frac>
pub const fn wrapping_next_power_of_two(self) -> FixedU32<Frac>
Returns the smallest power of two that is ≥ self
,
wrapping to 0 if the next power of two is too large to represent.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 3/8 is 0.0110
let three_eights = Fix::from_bits(0b0110);
// 1/2 is 0.1000
let half = Fix::from_bits(0b1000);
assert_eq!(three_eights.wrapping_next_power_of_two(), half);
assert_eq!(Fix::MAX.wrapping_next_power_of_two(), 0);
sourcepub const fn wrapping_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Wrapping addition with a signed fixed-point number. Returns the sum, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).wrapping_add_signed(IFix::from_num(-3)), 2);
assert_eq!(Fix::ZERO.wrapping_add_signed(-IFix::DELTA), Fix::MAX);
sourcepub const fn wrapping_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Wrapping subtraction with a signed fixed-point number. Returns the difference, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).wrapping_sub_signed(IFix::from_num(-3)), 8);
assert_eq!(Fix::ZERO.wrapping_sub_signed(IFix::DELTA), Fix::MAX);
sourcepub const fn unwrapped_neg(self) -> FixedU32<Frac>
pub const fn unwrapped_neg(self) -> FixedU32<Frac>
Unwrapped negation. Returns the negated value, panicking on overflow.
Only zero can be negated without overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.unwrapped_neg(), Fix::ZERO);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::from_num(5).unwrapped_neg();
sourcepub const fn unwrapped_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped addition. Returns the sum, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).unwrapped_add(Fix::from_num(2)), Fix::from_num(5));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_add(Fix::DELTA);
sourcepub const fn unwrapped_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped subtraction. Returns the difference, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(5).unwrapped_sub(Fix::from_num(3)), Fix::from_num(2));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MIN.unwrapped_sub(Fix::DELTA);
sourcepub const fn unwrapped_rem(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_rem(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped remainder. Returns the remainder, panicking if the divisor is zero.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(1.5).unwrapped_rem(Fix::ONE), Fix::from_num(0.5));
The following panics because the divisor is zero.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _divisor_is_zero = Fix::from_num(1.5).unwrapped_rem(Fix::ZERO);
sourcepub const fn unwrapped_mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn unwrapped_mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> FixedU32<Frac>
Unwrapped multiply and add.
Returns self
× mul
+ add
, panicking on overflow.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).unwrapped_mul_add(Fix::from_num(0.5), Fix::from_num(3)),
Fix::from_num(5)
);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_mul_add(Fix::ONE, Fix::DELTA);
sourcepub const fn unwrapped_mul_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_mul_int(self, rhs: u32) -> FixedU32<Frac>
Unwrapped multiplication by an integer. Returns the product, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).unwrapped_mul_int(2), Fix::from_num(6));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_mul_int(4);
sourcepub const fn unwrapped_div_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_div_int(self, rhs: u32) -> FixedU32<Frac>
Unwrapped division by an integer. Returns the quotient.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.5 is binary 1.1
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).unwrapped_div_int(2), one_point_5);
The following panics because the divisor is zero.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _divisor_is_zero = Fix::from_num(3).unwrapped_div_int(0);
sourcepub const fn unwrapped_rem_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_rem_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped remainder for Euclidean division. Returns the remainder, panicking if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let num = Fix::from_num(7.5);
assert_eq!(num.unwrapped_rem_euclid(Fix::from_num(2)), Fix::from_num(1.5));
The following panics because the divisor is zero.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _divisor_is_zero = Fix::from_num(3).unwrapped_rem_euclid(Fix::ZERO);
sourcepub const fn unwrapped_shl(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_shl(self, rhs: u32) -> FixedU32<Frac>
Unwrapped shift left. Panics if rhs
≥ 32.
§Panics
Panics if rhs
≥ 32.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::ONE / 2).unwrapped_shl(3), Fix::from_num(4));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::ONE.unwrapped_shl(32);
sourcepub const fn unwrapped_shr(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_shr(self, rhs: u32) -> FixedU32<Frac>
Unwrapped shift right. Panics if rhs
≥ 32.
§Panics
Panics if rhs
≥ 32.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::from_num(4)).unwrapped_shr(3), Fix::ONE / 2);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::ONE.unwrapped_shr(32);
sourcepub const fn unwrapped_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_dist(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped distance. Returns the distance from self
to other
.
The distance is the absolute value of the difference.
Can never overflow for unsigned types.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE.unwrapped_dist(Fix::from_num(5)), Fix::from_num(4));
assert_eq!(Fix::ZERO.unwrapped_dist(Fix::MAX), Fix::MAX);
sourcepub const fn unwrapped_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_hypot(self, other: FixedU32<Frac>) -> FixedU32<Frac>
Compute the hypotenuse of a right triange, panicking on overflow.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Panics
Panics if the result does not fit.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(
Fix::from_num(3).overflowing_hypot(Fix::from_num(4)),
(Fix::from_num(5), false)
);
The following panics because of overflow.
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(8, 15) == 17, which does not fit
let _overflow = Fix::from_num(8).unwrapped_hypot(Fix::from_num(15));
sourcepub const fn unwrapped_next_multiple_of(
self,
other: FixedU32<Frac>,
) -> FixedU32<Frac>
pub const fn unwrapped_next_multiple_of( self, other: FixedU32<Frac>, ) -> FixedU32<Frac>
Returns the next multiple of other
, panicking on overflow.
The next multiple is the smallest multiple of other
that is ≥ self
.
§Panics
Panics if other
is zero or on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).unwrapped_next_multiple_of(Fix::from_num(1.5)),
Fix::from_num(4.5)
);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_next_multiple_of(Fix::from_num(2));
sourcepub const fn unwrapped_inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> FixedU32<RetFrac>
pub const fn unwrapped_inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> FixedU32<RetFrac>
Inverse linear interpolation between start
and end
,
panicking on overflow.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Returns
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Panics
Panics when start
= end
or when the results overflows.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let four = Fix::from_num(4);
assert_eq!(Fix::from_num(3).unwrapped_inv_lerp::<U4>(two, four), 0.5);
The following panics because start
= end
.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let _zero_range = two.unwrapped_inv_lerp::<U4>(two, two);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_inv_lerp::<U4>(Fix::ZERO, Fix::from_num(0.5));
sourcepub const fn unwrapped_next_power_of_two(self) -> FixedU32<Frac>
pub const fn unwrapped_next_power_of_two(self) -> FixedU32<Frac>
Returns the smallest power of two that is ≥ self
,
panicking if the next power of two is too large to represent.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 3/8 is 0.0110
let three_eights = Fix::from_bits(0b0110);
// 1/2 is 0.1000
let half = Fix::from_bits(0b1000);
assert_eq!(three_eights.unwrapped_next_power_of_two(), half);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_next_power_of_two();
sourcepub const fn unwrapped_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_add_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Unwrapped addition with a signed fixed-point number. Returns the sum, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).unwrapped_add_signed(IFix::from_num(-3)), 2);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
let _overflow = Fix::from_num(2).unwrapped_add_signed(IFix::from_num(-3));
sourcepub const fn unwrapped_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_sub_signed(self, rhs: FixedI32<Frac>) -> FixedU32<Frac>
Unwrapped subtraction with a signed fixed-point number. Returns the difference, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(Fix::from_num(5).unwrapped_sub_signed(IFix::from_num(-3)), 8);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
let _overflow = Fix::from_num(2).unwrapped_sub_signed(IFix::from_num(3));
sourcepub const fn overflowing_neg(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_neg(self) -> (FixedU32<Frac>, bool)
Overflowing negation.
Returns a tuple of the negated value and a bool
indicating whether
an overflow has occurred. On overflow, the wrapped value is returned.
Only zero can be negated without overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.overflowing_neg(), (Fix::ZERO, false));
assert_eq!(Fix::from_num(5).overflowing_neg(), Fix::overflowing_from_num(-5));
let neg_five_bits = !Fix::from_num(5).to_bits() + 1;
assert_eq!(Fix::from_num(5).overflowing_neg(), (Fix::from_bits(neg_five_bits), true));
sourcepub const fn overflowing_add(
self,
rhs: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_add( self, rhs: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing addition.
Returns a tuple of the sum and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_minus_delta = Fix::ONE - Fix::DELTA;
assert_eq!(Fix::from_num(3).overflowing_add(Fix::from_num(2)), (Fix::from_num(5), false));
assert_eq!(Fix::MAX.overflowing_add(Fix::ONE), (one_minus_delta, true));
sourcepub const fn overflowing_sub(
self,
rhs: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_sub( self, rhs: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing subtraction.
Returns a tuple of the difference and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_minus_delta = Fix::ONE - Fix::DELTA;
assert_eq!(Fix::from_num(5).overflowing_sub(Fix::from_num(3)), (Fix::from_num(2), false));
assert_eq!(Fix::ZERO.overflowing_sub(Fix::ONE), (Fix::MAX - one_minus_delta, true));
sourcepub const fn overflowing_mul_add<MulFrac: LeEqU32>(
self,
mul: FixedU32<MulFrac>,
add: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_mul_add<MulFrac: LeEqU32>( self, mul: FixedU32<MulFrac>, add: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing multiply and add.
Returns a tuple of self
× mul
+ add
and a bool
indicating
whether an overflow has occurred. On overflow, the wrapped value is
returned.
The mul
parameter can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::MAX.overflowing_mul_add(Fix::ONE, Fix::ZERO),
(Fix::MAX, false)
);
assert_eq!(
Fix::MAX.overflowing_mul_add(Fix::ONE, Fix::DELTA),
(Fix::MIN, true)
);
assert_eq!(
Fix::MAX.overflowing_mul_add(Fix::from_num(3), Fix::MAX),
Fix::MAX.overflowing_mul_int(4)
);
sourcepub const fn overflowing_mul_int(self, rhs: u32) -> (FixedU32<Frac>, bool)
pub const fn overflowing_mul_int(self, rhs: u32) -> (FixedU32<Frac>, bool)
Overflowing multiplication by an integer.
Returns a tuple of the product and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).overflowing_mul_int(2), (Fix::from_num(6), false));
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.overflowing_mul_int(4), (wrapped, true));
sourcepub const fn overflowing_div_int(self, rhs: u32) -> (FixedU32<Frac>, bool)
pub const fn overflowing_div_int(self, rhs: u32) -> (FixedU32<Frac>, bool)
Overflowing division by an integer.
Returns a tuple of the quotient and false
, as the division can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.5 is binary 1.1
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).overflowing_div_int(2), (one_point_5, false));
sourcepub const fn overflowing_shl(self, rhs: u32) -> (FixedU32<Frac>, bool)
pub const fn overflowing_shl(self, rhs: u32) -> (FixedU32<Frac>, bool)
Overflowing shift left.
Returns a tuple of the shifted value and a bool
indicating whether
an overflow has occurred. Overflow occurs when rhs
≥ 32.
On overflow rhs
is wrapped before the shift operation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::ONE / 2).overflowing_shl(3), (Fix::from_num(4), false));
assert_eq!((Fix::ONE / 2).overflowing_shl(3 + 32), (Fix::from_num(4), true));
sourcepub const fn overflowing_shr(self, rhs: u32) -> (FixedU32<Frac>, bool)
pub const fn overflowing_shr(self, rhs: u32) -> (FixedU32<Frac>, bool)
Overflowing shift right.
Returns a tuple of the shifted value and a bool
indicating whether
an overflow has occurred. Overflow occurs when rhs
≥ 32.
On overflow rhs
is wrapped before the shift operation.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!((Fix::from_num(4)).overflowing_shr(3), (Fix::ONE / 2, false));
assert_eq!((Fix::from_num(4)).overflowing_shr(3 + 32), (Fix::ONE / 2, true));
sourcepub const fn overflowing_dist(
self,
other: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_dist( self, other: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing distance.
Returns a tuple of the distance from self
to other
and false
, as overflow can never happen for unsigned types.
The distance is the absolute value of the difference.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::ONE.overflowing_dist(Fix::from_num(5)),
(Fix::from_num(4), false)
);
assert_eq!(
Fix::ZERO.overflowing_dist(Fix::MAX),
(Fix::MAX, false)
);
sourcepub const fn overflowing_hypot(
self,
other: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_hypot( self, other: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Compute the hypotenuse of a right triange.
Returns a tuple of the hypotenuse and a bool
, indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
The hypotenuse is equal to the square root of the sum of the squares of the operands.
This method uses an iterative method for its square root, with up to 32
iterations for FixedU32
. The result is rounded down, and the
error is < DELTA
. That is,
result ≤ √(self
² + other
²) < result + DELTA
.
§Examples
use fixed::types::extra::U28;
use fixed::FixedU32;
type Fix = FixedU32<U28>;
// hypot(3, 4) == 5
assert_eq!(
Fix::from_num(3).overflowing_hypot(Fix::from_num(4)),
(Fix::from_num(5), false)
);
// hypot(8, 15) == 17, which wraps to 1
assert_eq!(
Fix::from_num(8).overflowing_hypot(Fix::from_num(15)),
(Fix::from_num(1), true)
);
sourcepub const fn overflowing_next_multiple_of(
self,
other: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_next_multiple_of( self, other: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing next multiple of other
.
Returns a tuple of the next multiple and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
The next multiple is the smallest multiple of other
that is ≥ self
.
§Panics
Panics if other
is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(4).overflowing_next_multiple_of(Fix::from_num(1.5)),
(Fix::from_num(4.5), false)
);
let max_minus_delta = Fix::MAX - Fix::DELTA;
assert_eq!(
Fix::MAX.overflowing_next_multiple_of(max_minus_delta),
(max_minus_delta.wrapping_mul_int(2), true)
);
sourcepub const fn overflowing_inv_lerp<RetFrac: LeEqU32>(
self,
start: FixedU32<Frac>,
end: FixedU32<Frac>,
) -> (FixedU32<RetFrac>, bool)
pub const fn overflowing_inv_lerp<RetFrac: LeEqU32>( self, start: FixedU32<Frac>, end: FixedU32<Frac>, ) -> (FixedU32<RetFrac>, bool)
Overflowing inverse linear interpolation between start
and end
.
Returns a tuple of the result and a bool
indicationg whether an overflow
has occurred. On overflow, the wrapped value is returned.
The computed value can have a fixed-point type like self
but with a different
number of fractional bits.
Computes
(self
− start
) / (end
− start
).
This is 0 when self
= start
, and 1 when self
= end
.
§Panics
Panics when start
= end
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let two = Fix::from_num(2);
let four = Fix::from_num(4);
assert_eq!(
Fix::from_num(3).overflowing_inv_lerp::<U4>(two, four),
(Fix::from_num(0.5), false)
);
assert_eq!(
Fix::MAX.overflowing_inv_lerp::<U4>(Fix::ZERO, Fix::from_num(0.5)),
(Fix::MAX.wrapping_mul_int(2), true)
);
sourcepub const fn overflowing_add_signed(
self,
rhs: FixedI32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_add_signed( self, rhs: FixedI32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing addition with a signed fixed-point number.
Returns a tuple of the sum and a bool
indicating
whether an overflow has occurred. On overflow, the wrapped
value is returned.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(
Fix::from_num(5).overflowing_add_signed(IFix::from_num(-3)),
(Fix::from_num(2), false)
);
assert_eq!(
Fix::ZERO.overflowing_add_signed(-IFix::DELTA),
(Fix::MAX, true)
);
sourcepub const fn overflowing_sub_signed(
self,
rhs: FixedI32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_sub_signed( self, rhs: FixedI32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing subtraction with a signed fixed-point number.
Returns a tuple of the difference and a bool
indicating whether an overflow has occurred. On overflow,
the wrapped value is returned.
§Examples
use fixed::{types::extra::U4, FixedI32, FixedU32};
type Fix = FixedU32<U4>;
type IFix = FixedI32<U4>;
assert_eq!(
Fix::from_num(5).overflowing_sub_signed(IFix::from_num(-3)),
(Fix::from_num(8), false)
);
assert_eq!(
Fix::ZERO.overflowing_sub_signed(IFix::DELTA),
(Fix::MAX, true)
);
sourcepub const unsafe fn unchecked_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const unsafe fn unchecked_add(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unchecked addition. Computes self
+ rhs
, assuming
overflow cannot occur.
Calling x.unchecked_add(y)
is semantically equivalent to
calling
x.checked_add(y).unwrap_unchecked()
.
If you’re just trying to avoid the panic in debug mode, then
do not use this. Instead, you’re looking for
wrapping_add
.
§Safety
This results in undefined behavior when
self
+ rhs
> MAX
.
sourcepub const unsafe fn unchecked_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const unsafe fn unchecked_sub(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unchecked subtraction. Computes self
− rhs
,
assuming overflow cannot occur.
Calling x.unchecked_sub(y)
is semantically equivalent to
calling
x.checked_sub(y).unwrap_unchecked()
.
If you’re just trying to avoid the panic in debug mode, then
do not use this. Instead, you’re looking for
wrapping_sub
.
§Safety
This results in undefined behavior when
self
− rhs
> MAX
.
sourcepub const unsafe fn unchecked_mul_int(self, rhs: u32) -> FixedU32<Frac>
pub const unsafe fn unchecked_mul_int(self, rhs: u32) -> FixedU32<Frac>
Unchecked multiplication by an integer. Computes
self
× rhs
, assuming overflow cannot occur.
Calling x.unchecked_mul_int(y)
is semantically equivalent to
calling
x.checked_mul_int(y).unwrap_unchecked()
.
If you’re just trying to avoid the panic in debug mode, then
do not use this. Instead, you’re looking for
wrapping_mul_int
.
§Safety
This results in undefined behavior when
self
× rhs
> MAX
.
source§impl<Frac: LeEqU32> FixedU32<Frac>
impl<Frac: LeEqU32> FixedU32<Frac>
The implementation of items in this block depends on the
number of fractional bits Frac
.
sourcepub const INT_NBITS: u32 = _
pub const INT_NBITS: u32 = _
The number of integer bits.
§Examples
use fixed::{types::extra::U6, FixedU32};
type Fix = FixedU32<U6>;
assert_eq!(Fix::INT_NBITS, 32 - 6);
sourcepub const FRAC_NBITS: u32 = Frac::U32
pub const FRAC_NBITS: u32 = Frac::U32
The number of fractional bits.
§Examples
use fixed::{types::extra::U6, FixedU32};
type Fix = FixedU32<U6>;
assert_eq!(Fix::FRAC_NBITS, 6);
sourcepub fn from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
pub fn from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
Creates a fixed-point number from another number.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.to_fixed()
.
§Panics
For floating-point numbers, panics if the value is not finite.
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_num
instead.
§Examples
use fixed::{types::extra::U4, types::I16F16, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(Fix::from_num(src), Fix::from_bits(0b111 << (4 - 2)));
assert_eq!(Fix::from_num(3i32), Fix::from_bits(3 << 4));
assert_eq!(Fix::from_num(3i64), Fix::from_bits(3 << 4));
assert_eq!(Fix::from_num(1.75f32), Fix::from_bits(0b111 << (4 - 2)));
assert_eq!(Fix::from_num(1.75f64), Fix::from_bits(0b111 << (4-2)));
sourcepub fn to_num<Dst: FromFixed>(self) -> Dst
pub fn to_num<Dst: FromFixed>(self) -> Dst
Converts a fixed-point number to another number.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::from_fixed(self)
.
§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_num
instead.
§Examples
use fixed::{types::extra::U4, types::I30F2, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(src.to_num::<I30F2>(), I30F2::from_bits(0b111));
// src >> 2 is 0.0111, which for I30F2 is truncated to 0.01
assert_eq!((src >> 2u32).to_num::<I30F2>(), I30F2::from_bits(0b1));
// 2.5 is 10.1 in binary
let two_point_5 = Fix::from_bits(0b101 << (4 - 1));
assert_eq!(two_point_5.to_num::<i32>(), 2);
assert_eq!(two_point_5.to_num::<i64>(), 2);
// 1.625 is 1.101 in binary
let one_point_625 = Fix::from_bits(0b1101 << (4 - 3));
assert_eq!(one_point_625.to_num::<f32>(), 1.625f32);
assert_eq!(one_point_625.to_num::<f64>(), 1.625f64);
sourcepub fn checked_from_num<Src: ToFixed>(src: Src) -> Option<FixedU32<Frac>>
pub fn checked_from_num<Src: ToFixed>(src: Src) -> Option<FixedU32<Frac>>
Creates a fixed-point number from another number if it
fits, otherwise returns None
.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.checked_to_fixed()
.
§Examples
use fixed::{
types::extra::{U2, U4},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(Fix::checked_from_num(src), Some(Fix::from_bits(0b111 << (4 - 2))));
let too_large = FixedU32::<U2>::MAX;
assert!(Fix::checked_from_num(too_large).is_none());
assert_eq!(Fix::checked_from_num(3), Some(Fix::from_bits(3 << 4)));
let too_large = u32::MAX;
assert!(Fix::checked_from_num(too_large).is_none());
let too_small = -1;
assert!(Fix::checked_from_num(too_small).is_none());
// 1.75 is 1.11 in binary
let expected = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(Fix::checked_from_num(1.75f32), Some(expected));
assert_eq!(Fix::checked_from_num(1.75f64), Some(expected));
assert!(Fix::checked_from_num(2e38).is_none());
assert!(Fix::checked_from_num(std::f64::NAN).is_none());
sourcepub fn checked_to_num<Dst: FromFixed>(self) -> Option<Dst>
pub fn checked_to_num<Dst: FromFixed>(self) -> Option<Dst>
Converts a fixed-point number to another number if it
fits, otherwise returns None
.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::checked_from_fixed(self)
.
§Examples
use fixed::{
types::extra::{U0, U4, U6},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
let expected = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(src.checked_to_num::<I16F16>(), Some(expected));
type TooFewIntBits = FixedU32<U6>;
assert!(Fix::MAX.checked_to_num::<TooFewIntBits>().is_none());
// 2.5 is 10.1 in binary
let two_point_5 = Fix::from_bits(0b101 << (4 - 1));
assert_eq!(two_point_5.checked_to_num::<i32>(), Some(2));
assert_eq!(two_point_5.checked_to_num::<i64>(), Some(2));
type AllInt = FixedU32<U0>;
assert!(AllInt::MAX.checked_to_num::<i32>().is_none());
// 1.625 is 1.101 in binary
let one_point_625 = Fix::from_bits(0b1101 << (4 - 3));
assert_eq!(one_point_625.checked_to_num::<f32>(), Some(1.625f32));
sourcepub fn saturating_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
pub fn saturating_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
Creates a fixed-point number from another number, saturating if it does not fit.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.saturating_to_fixed()
.
§Panics
This method panics if the value is a floating-point NaN.
§Examples
use fixed::{
types::extra::{U2, U4},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(Fix::saturating_from_num(src), Fix::from_bits(0b111 << (4 - 2)));
let too_large = FixedU32::<U2>::MAX;
assert_eq!(Fix::saturating_from_num(too_large), Fix::MAX);
assert_eq!(Fix::saturating_from_num(3), Fix::from_bits(3 << 4));
let too_small = -1;
assert_eq!(Fix::saturating_from_num(too_small), Fix::MIN);
// 1.75 is 1.11 in binary
let expected = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(Fix::saturating_from_num(1.75f32), expected);
assert_eq!(Fix::saturating_from_num(1.75f64), expected);
assert_eq!(Fix::saturating_from_num(2e38), Fix::MAX);
assert_eq!(Fix::saturating_from_num(std::f64::NEG_INFINITY), Fix::MIN);
sourcepub fn saturating_to_num<Dst: FromFixed>(self) -> Dst
pub fn saturating_to_num<Dst: FromFixed>(self) -> Dst
Converts a fixed-point number to another number, saturating the value if it does not fit.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::saturating_from_fixed(self)
.
§Examples
use fixed::{
types::extra::{U0, U4, U6},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
let expected = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(src.saturating_to_num::<I16F16>(), expected);
type TooFewIntBits = FixedU32<U6>;
let saturated = Fix::MAX.saturating_to_num::<TooFewIntBits>();
assert_eq!(saturated, TooFewIntBits::MAX);
// 2.5 is 10.1 in binary
let two_point_5 = Fix::from_bits(0b101 << (4 - 1));
assert_eq!(two_point_5.saturating_to_num::<i32>(), 2);
type AllInt = FixedU32<U0>;
assert_eq!(AllInt::MAX.saturating_to_num::<i32>(), i32::MAX);
// 1.625 is 1.101 in binary
let one_point_625 = Fix::from_bits(0b1101 << (4 - 3));
assert_eq!(one_point_625.saturating_to_num::<f32>(), 1.625f32);
sourcepub fn wrapping_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
pub fn wrapping_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
Creates a fixed-point number from another number, wrapping the value on overflow.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.wrapping_to_fixed()
.
§Panics
For floating-point numbers, panics if the value is not finite.
§Examples
use fixed::{
types::extra::{U0, U4},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(Fix::wrapping_from_num(src), Fix::from_bits(0b111 << (4 - 2)));
// integer 0b1101 << (32 - 7) will wrap to fixed-point 1010...
let too_large = FixedU32::<U0>::from_bits(0b1101 << (32 - 7));
let wrapped = Fix::from_bits(0b1010 << (32 - 4));
assert_eq!(Fix::wrapping_from_num(too_large), wrapped);
// integer 0b1101 << (32 - 7) will wrap to fixed-point 1010...
let large: u32 = 0b1101 << (32 - 7);
let wrapped = Fix::from_bits(0b1010 << (32 - 4));
assert_eq!(Fix::wrapping_from_num(large), wrapped);
// 1.75 is 1.11 in binary
let expected = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(Fix::wrapping_from_num(1.75f32), expected);
// 1.75 << (32 - 4) wraps to binary 11000...
let large = 1.75 * 2f32.powi(32 - 4);
let wrapped = Fix::from_bits(0b1100 << (32 - 4));
assert_eq!(Fix::wrapping_from_num(large), wrapped);
sourcepub fn wrapping_to_num<Dst: FromFixed>(self) -> Dst
pub fn wrapping_to_num<Dst: FromFixed>(self) -> Dst
Converts a fixed-point number to another number, wrapping the value on overflow.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::wrapping_from_fixed(self)
.
§Examples
use fixed::{
types::extra::{U0, U4, U6},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
let expected = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(src.wrapping_to_num::<I16F16>(), expected);
type TooFewIntBits = FixedU32<U6>;
let wrapped = TooFewIntBits::from_bits(Fix::MAX.to_bits() << 2);
assert_eq!(Fix::MAX.wrapping_to_num::<TooFewIntBits>(), wrapped);
// 2.5 is 10.1 in binary
let two_point_5 = Fix::from_bits(0b101 << (4 - 1));
assert_eq!(two_point_5.wrapping_to_num::<i32>(), 2);
type AllInt = FixedU32<U0>;
assert_eq!(AllInt::MAX.wrapping_to_num::<i32>(), -1);
// 1.625 is 1.101 in binary
let one_point_625 = Fix::from_bits(0b1101 << (4 - 3));
assert_eq!(one_point_625.wrapping_to_num::<f32>(), 1.625f32);
sourcepub fn unwrapped_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
pub fn unwrapped_from_num<Src: ToFixed>(src: Src) -> FixedU32<Frac>
Creates a fixed-point number from another number, panicking on overflow.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.unwrapped_to_fixed()
.
§Panics
Panics if the value does not fit.
For floating-point numbers, also panics if the value is not finite.
§Examples
use fixed::{
types::{extra::U4, I16F16},
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(Fix::unwrapped_from_num(src), Fix::from_bits(0b111 << (4 - 2)));
The following panics because of overflow.
use fixed::{
types::extra::{U0, U4},
FixedU32,
};
type Fix = FixedU32<U4>;
let too_large = FixedU32::<U0>::from_bits(0b1101 << (32 - 7));
let _overflow = Fix::unwrapped_from_num(too_large);
sourcepub fn unwrapped_to_num<Dst: FromFixed>(self) -> Dst
pub fn unwrapped_to_num<Dst: FromFixed>(self) -> Dst
Converts a fixed-point number to another number, panicking on overflow.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::unwrapped_from_fixed(self)
.
§Panics
Panics if the value does not fit.
§Examples
use fixed::{
types::{extra::U4, I16F16},
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
let expected = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(src.unwrapped_to_num::<I16F16>(), expected);
The following panics because of overflow.
use fixed::{
types::extra::{U4, U6},
FixedU32,
};
type Fix = FixedU32<U4>;
type TooFewIntBits = FixedU32<U6>;
let _overflow = Fix::MAX.unwrapped_to_num::<TooFewIntBits>();
sourcepub fn overflowing_from_num<Src: ToFixed>(src: Src) -> (FixedU32<Frac>, bool)
pub fn overflowing_from_num<Src: ToFixed>(src: Src) -> (FixedU32<Frac>, bool)
Creates a fixed-point number from another 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.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other number
src
for whichToFixed
is implemented, in which case this method returnssrc.overflowing_to_fixed()
.
§Panics
For floating-point numbers, panics if the value is not finite.
§Examples
use fixed::{
types::extra::{U0, U4},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = I16F16::from_bits(0b111 << (16 - 2));
let expected = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(Fix::overflowing_from_num(src), (expected, false));
// integer 0b1101 << (32 - 7) will wrap to fixed-point 1010...
let too_large = FixedU32::<U0>::from_bits(0b1101 << (32 - 7));
let wrapped = Fix::from_bits(0b1010 << (32 - 4));
assert_eq!(Fix::overflowing_from_num(too_large), (wrapped, true));
assert_eq!(Fix::overflowing_from_num(3), (Fix::from_bits(3 << 4), false));
// integer 0b1101 << (32 - 7) will wrap to fixed-point 1010...
let large: u32 = 0b1101 << (32 - 7);
let wrapped = Fix::from_bits(0b1010 << (32 - 4));
assert_eq!(Fix::overflowing_from_num(large), (wrapped, true));
// 1.75 is 1.11 in binary
let expected = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(Fix::overflowing_from_num(1.75f32), (expected, false));
// 1.75 << (32 - 4) wraps to binary 11000...
let large = 1.75 * 2f32.powi(32 - 4);
let wrapped = Fix::from_bits(0b1100 << (32 - 4));
assert_eq!(Fix::overflowing_from_num(large), (wrapped, true));
sourcepub fn overflowing_to_num<Dst: FromFixed>(self) -> (Dst, bool)
pub fn overflowing_to_num<Dst: FromFixed>(self) -> (Dst, bool)
Converts a fixed-point number to another number.
Returns a tuple of the number and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
The other number can be:
- Another fixed-point number. Any extra fractional bits are discarded, which rounds towards −∞.
- An integer of type
i8
,i16
,i32
,i64
,i128
,isize
,u8
,u16
,u32
,u64
,u128
, orusize
. Any fractional bits are discarded, which rounds towards −∞. - A floating-point number of type
half::f16
,half::bf16
,f32
,f64
orF128
. For this conversion, the method rounds to the nearest, with ties rounding to even. - Any other type
Dst
for whichFromFixed
is implemented, in which case this method returnsDst::overflowing_from_fixed(self)
.
§Examples
use fixed::{
types::extra::{U0, U4, U6},
types::I16F16,
FixedU32,
};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let src = Fix::from_bits(0b111 << (4 - 2));
let expected = I16F16::from_bits(0b111 << (16 - 2));
assert_eq!(src.overflowing_to_num::<I16F16>(), (expected, false));
type TooFewIntBits = FixedU32<U6>;
let wrapped = TooFewIntBits::from_bits(Fix::MAX.to_bits() << 2);
assert_eq!(Fix::MAX.overflowing_to_num::<TooFewIntBits>(), (wrapped, true));
// 2.5 is 10.1 in binary
let two_point_5 = Fix::from_bits(0b101 << (4 - 1));
assert_eq!(two_point_5.overflowing_to_num::<i32>(), (2, false));
let does_not_fit = FixedU32::<U0>::MAX;
let wrapped = -1i32;
assert_eq!(does_not_fit.overflowing_to_num::<i32>(), (wrapped, true));
// 1.625 is 1.101 in binary
let one_point_625 = Fix::from_bits(0b1101 << (4 - 3));
assert_eq!(one_point_625.overflowing_to_num::<f32>(), (1.625f32, false));
sourcepub const fn const_from_fixed<SrcFrac: LeEqU32>(
src: FixedU32<SrcFrac>,
) -> FixedU32<Frac>
pub const fn const_from_fixed<SrcFrac: LeEqU32>( src: FixedU32<SrcFrac>, ) -> FixedU32<Frac>
Creates a fixed-point number from a fixed-point number with the same underlying integer type. Usable in constant context.
This is equivalent to the unwrapped_from_num
method with
FixedU32<SrcFrac>
as its generic parameter, but can also be used in constant context.
Unless required in constant context, use unwrapped_from_num
or
from_num
instead.
§Planned deprecation
This method will be deprecated when the unwrapped_from_num
method is usable in constant context.
§Panics
Panics if the value does not fit.
§Examples
use fixed::types::extra::{U2, U4};
use fixed::FixedU32;
type FixA = FixedU32<U2>;
type FixB = FixedU32<U4>;
const A: FixA = FixA::unwrapped_from_str("3.5");
const B: FixB = FixB::const_from_fixed(A);
assert_eq!(B, 3.5);
The following would fail to compile because of overflow.
use fixed::types::extra::{U2, U4};
use fixed::FixedU32;
const _OVERFLOW: FixedU32<U4> = FixedU32::const_from_fixed(FixedU32::<U2>::MAX);
sourcepub const fn const_from_int(src: u32) -> FixedU32<Frac>
pub const fn const_from_int(src: u32) -> FixedU32<Frac>
Creates a fixed-point number from the underlying integer type
u32
.
Usable in constant context.
This is equivalent to the unwrapped_from_num
method with
u32
as its generic parameter, but can also be used in constant context.
Unless required in constant context, use unwrapped_from_num
or
from_num
instead.
§Planned deprecation
This method will be deprecated when the unwrapped_from_num
method is usable in constant context.
§Panics
Panics if the value does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const FIVE: Fix = Fix::const_from_int(5);
assert_eq!(FIVE, 5);
The following would fail to compile because of overflow.
use fixed::{types::extra::U4, FixedU32};
const _OVERFLOW: FixedU32<U4> = FixedU32::const_from_int(u32::MAX);
sourcepub const fn lit(src: &str) -> FixedU32<Frac>
pub const fn lit(src: &str) -> FixedU32<Frac>
Parses a fixed-point literal.
Rounding is to the nearest, with ties rounded to even.
This is similar to from_str
but accepts a prefix for setting
the radix, and ignores underscores, such that the parsing is more similar to
numeric literals in Rust code.
Strings starting with “0b
” are parsed as binary, strings
starting with “0o
” are parsed as octal, and strings starting with “0x
” are
parsed as hexadecimal.
Exponents are supported as well. For decimal, binary and octal numbers, the
separator “e
” or “E
” can be used to start an exponent, which is then
followed by an optional sign “+
” or “-
”, and then by a decimal integer which
is the exponent. For hexadecimal numbers, since “e
” and “E
” are hexadecimal
digits, the separator “@
” has to be used instead. The separator “@
” is
accepted for all radices. The parsed value is scaled by the radix to the power
of the exponent.
For binary, octal and hexadecimal, base-2 exponents are supported too, using the
separator “p
” or “P
”. The parsed value is scaled by 2 to the power of the
exponent. For example, for hexadecimal “P8
” means ×2⁸, and is equivalent to
“@2
” which means ×16².
§Constants
The lit
method is useful to write constant fixed-point literals, and can be
evaluated in constant context.
Warning: Normal calls to the lit
method are not evaluated at compile
time. To ensure that the call is evaluated at compile time, lit
must be used
in an inline constant expression, or used to initialize a constant.
For example, here lit
would be evaluated at compile time:
const ONE_AND_HALF: Fix = Fix::lit("1.5");
However, here lit
would be evaluated at run time:
// Evaluated at run time.
let one_and_half = Fix::lit("1.5");
To evaluate at compile time without introducing a constant into the scope:
let one_and_half = const { Fix::lit("1.5") };
§Panics
Panics if the number is not valid or overflows.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::lit("1.75"), 1.75);
assert_eq!(Fix::lit("1_.7_5_"), 1.75);
assert_eq!(Fix::lit("17.5e-1"), 1.75);
assert_eq!(Fix::lit("0_.017_5_e+0_2"), 1.75);
assert_eq!(Fix::lit("0b1.11"), 1.75);
assert_eq!(Fix::lit("0b_111e-2"), 1.75);
assert_eq!(Fix::lit("0o1.6"), 1.75);
assert_eq!(Fix::lit("0o.16E1"), 1.75);
assert_eq!(Fix::lit("0o7p-2"), 1.75);
assert_eq!(Fix::lit("0x1.C"), 1.75);
assert_eq!(Fix::lit("0x0.1C@1"), 1.75);
This method is useful to write constant fixed-point literals.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
const ONE_AND_HALF: Fix = Fix::lit("1.5");
assert_eq!(ONE_AND_HALF, 1.5);
sourcepub const fn from_str(src: &str) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn from_str(src: &str) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing decimal digits to return a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
The number can have an optional exponent. The separator “e
”, “E
” or “@
”
can be used to start an exponent, which is then followed by an optional sign
“+
” or “-
”, and then by a decimal integer which is the exponent. The parsed
value is scaled by 10 to the power of the exponent.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_str("1.75"), Ok(Fix::from_num(1.75)));
assert_eq!(Fix::from_str("0.00625E+3"), Ok(Fix::from_num(6.25)));
assert_eq!(Fix::from_str("1.25e-1"), Ok(Fix::from_num(0.125)));
sourcepub const fn from_str_binary(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn from_str_binary( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing binary digits to return a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
The number can have an optional exponent. The separator “e
”, “E
” or “@
”
can be used to start an exponent, which is then followed by an optional sign
“+
” or “-
”, and then by a decimal integer which is the exponent. The parsed
value is scaled by the radix (2 for binary) to the power of the exponent.
Base-2 exponents are supported too, using the separator “p
” or “P
”. The
parsed value is scaled by 2 to the power of the exponent. For binary, since the
radix is 2, base-2 exponents are equivalent to the other form of exponent.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.11 in binary is 1.75
assert_eq!(Fix::from_str_binary("1.11"), Ok(Fix::from_num(1.75)));
// 111.0101 in binary is 7.3125
assert_eq!(Fix::from_str_binary("1.110101e2"), Ok(Fix::from_num(7.3125)));
assert_eq!(Fix::from_str_binary("11101.01e-2"), Ok(Fix::from_num(7.3125)));
sourcepub const fn from_str_octal(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn from_str_octal( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing octal digits to return a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
The number can have an optional exponent. The separator “e
”, “E
” or “@
”
can be used to start an exponent, which is then followed by an optional sign
“+
” or “-
”, and then by a decimal integer which is the exponent. The parsed
value is scaled by 8 to the power of the exponent.
Base-2 exponents are supported too, using the separator “p
” or “P
”. The
parsed value is scaled by 2 to the power of the exponent. For example, for octal
“P6
” means ×2⁶, and is equivalent to “E2
” which means ×8².
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary, 1.6 in octal
let f = Fix::from_str_octal("1.6");
let check = Fix::from_bits(0b111 << (4 - 2));
assert_eq!(f, Ok(check));
assert_eq!(Fix::from_str_octal("160e-2"), Ok(check));
sourcepub const fn from_str_hex(src: &str) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn from_str_hex(src: &str) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing hexadecimal digits to return a fixed-point number.
Rounding is to the nearest, with ties rounded to even.
The number can have an optional exponent. Since “e
” and “E
” are valid
hexadecimal digits, they cannot be used as a separator to start an exponent, so
“@
” is used instead. This is then followed by an optional sign “+
” or “-
”,
and then by a decimal integer which is the exponent. The parsed value is scaled
by 16 to the power of the exponent.
Base-2 exponents are supported too, using the separator “p
” or “P
”. The
parsed value is scaled by 2 to the power of the exponent. For example, for
hexadecimal “P8
” means ×2⁸, and is equivalent to “@2
” which means ×16².
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.C in hexadecimal is 1.75
assert_eq!(Fix::from_str_hex("1.C"), Ok(Fix::from_num(1.75)));
assert_eq!(Fix::from_str_hex("1C@-1"), Ok(Fix::from_num(1.75)));
assert_eq!(Fix::from_str_hex(".01C@+2"), Ok(Fix::from_num(1.75)));
sourcepub const fn saturating_from_str(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn saturating_from_str( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing decimal digits to return a fixed-point number, saturating on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
assert_eq!(U8F8::saturating_from_str("9999"), Ok(U8F8::MAX));
assert_eq!(U8F8::saturating_from_str("-1"), Ok(U8F8::ZERO));
sourcepub const fn saturating_from_str_binary(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn saturating_from_str_binary( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing binary digits to return a fixed-point number, saturating on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
assert_eq!(U8F8::saturating_from_str_binary("101100111000"), Ok(U8F8::MAX));
assert_eq!(U8F8::saturating_from_str_binary("-1"), Ok(U8F8::ZERO));
sourcepub const fn saturating_from_str_octal(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn saturating_from_str_octal( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing octal digits to return a fixed-point number, saturating on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
assert_eq!(U8F8::saturating_from_str_octal("7777"), Ok(U8F8::MAX));
assert_eq!(U8F8::saturating_from_str_octal("-1"), Ok(U8F8::ZERO));
sourcepub const fn saturating_from_str_hex(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn saturating_from_str_hex( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Prases a string slice containing hexadecimal digits to return a fixed-point number, saturating on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
assert_eq!(U8F8::saturating_from_str_hex("FFFF"), Ok(U8F8::MAX));
assert_eq!(U8F8::saturating_from_str_hex("-1"), Ok(U8F8::ZERO));
sourcepub const fn wrapping_from_str(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn wrapping_from_str( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing decimal digits to return a fixed-point number, wrapping on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
// 9999.5 = 15.5 + 256 × n
assert_eq!(U8F8::wrapping_from_str("9999.5"), Ok(U8F8::from_num(15.5)));
assert_eq!(U8F8::wrapping_from_str("-9999.5"), Ok(U8F8::from_num(240.5)));
sourcepub const fn wrapping_from_str_binary(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn wrapping_from_str_binary( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing binary digits to return a fixed-point number, wrapping on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0b1110001 << (8 - 1));
assert_eq!(U8F8::wrapping_from_str_binary("101100111000.1"), Ok(check));
assert_eq!(U8F8::wrapping_from_str_binary("-101100111000.1"), Ok(check.wrapping_neg()));
sourcepub const fn wrapping_from_str_octal(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn wrapping_from_str_octal( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing octal digits to return a fixed-point number, wrapping on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0o1654 << (8 - 3));
assert_eq!(U8F8::wrapping_from_str_octal("7165.4"), Ok(check));
assert_eq!(U8F8::wrapping_from_str_octal("-7165.4"), Ok(check.wrapping_neg()));
sourcepub const fn wrapping_from_str_hex(
src: &str,
) -> Result<FixedU32<Frac>, ParseFixedError>
pub const fn wrapping_from_str_hex( src: &str, ) -> Result<FixedU32<Frac>, ParseFixedError>
Parses a string slice containing hexadecimal digits to return a fixed-point number, wrapping on overflow.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0xFFE);
assert_eq!(U8F8::wrapping_from_str_hex("C0F.FE"), Ok(check));
assert_eq!(U8F8::wrapping_from_str_hex("-C0F.FE"), Ok(check.wrapping_neg()));
sourcepub const fn unwrapped_from_str(src: &str) -> FixedU32<Frac>
pub const fn unwrapped_from_str(src: &str) -> FixedU32<Frac>
Parses a string slice containing decimal digits to return a fixed-point number, panicking on overflow.
Rounding is to the nearest, with ties rounded to even.
§Panics
Panics if the value does not fit or if there is a parsing error.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let f = Fix::unwrapped_from_str("1.75");
assert_eq!(f, Fix::from_bits(0b111 << (4 - 2)));
The following panics because of a parsing error.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _error = Fix::unwrapped_from_str("1.75.");
sourcepub const fn unwrapped_from_str_binary(src: &str) -> FixedU32<Frac>
pub const fn unwrapped_from_str_binary(src: &str) -> FixedU32<Frac>
Parses a string slice containing binary digits to return a fixed-point number, panicking on overflow.
Rounding is to the nearest, with ties rounded to even.
§Panics
Panics if the value does not fit or if there is a parsing error.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary
let f = Fix::unwrapped_from_str_binary("1.11");
assert_eq!(f, Fix::from_bits(0b111 << (4 - 2)));
The following panics because of a parsing error.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _error = Fix::unwrapped_from_str_binary("1.2");
sourcepub const fn unwrapped_from_str_octal(src: &str) -> FixedU32<Frac>
pub const fn unwrapped_from_str_octal(src: &str) -> FixedU32<Frac>
Parses a string slice containing octal digits to return a fixed-point number, panicking on overflow.
Rounding is to the nearest, with ties rounded to even.
§Panics
Panics if the value does not fit or if there is a parsing error.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary, 1.6 in octal
let f = Fix::unwrapped_from_str_octal("1.6");
assert_eq!(f, Fix::from_bits(0b111 << (4 - 2)));
The following panics because of a parsing error.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _error = Fix::unwrapped_from_str_octal("1.8");
sourcepub const fn unwrapped_from_str_hex(src: &str) -> FixedU32<Frac>
pub const fn unwrapped_from_str_hex(src: &str) -> FixedU32<Frac>
Parses a string slice containing hexadecimal digits to return a fixed-point number, wrapping on overflow.
Rounding is to the nearest, with ties rounded to even.
§Panics
Panics if the value does not fit or if there is a parsing error.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 1.75 is 1.11 in binary, 1.C in hexadecimal
let f = Fix::unwrapped_from_str_hex("1.C");
assert_eq!(f, Fix::from_bits(0b111 << (4 - 2)));
The following panics because of a parsing error.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _error = Fix::unwrapped_from_str_hex("1.G");
sourcepub const fn overflowing_from_str(
src: &str,
) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
pub const fn overflowing_from_str( src: &str, ) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
Parses a string slice containing decimal digits to return 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.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
assert_eq!(U8F8::overflowing_from_str("99.5"), Ok((U8F8::from_num(99.5), false)));
// 9999.5 = 15.5 + 256 × n
assert_eq!(U8F8::overflowing_from_str("9999.5"), Ok((U8F8::from_num(15.5), true)));
sourcepub const fn overflowing_from_str_binary(
src: &str,
) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
pub const fn overflowing_from_str_binary( src: &str, ) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
Parses a string slice containing binary digits to return 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.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0b1110001 << (8 - 1));
assert_eq!(U8F8::overflowing_from_str_binary("111000.1"), Ok((check, false)));
assert_eq!(U8F8::overflowing_from_str_binary("101100111000.1"), Ok((check, true)));
sourcepub const fn overflowing_from_str_octal(
src: &str,
) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
pub const fn overflowing_from_str_octal( src: &str, ) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
Parses a string slice containing octal digits to return 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.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0o1654 << (8 - 3));
assert_eq!(U8F8::overflowing_from_str_octal("165.4"), Ok((check, false)));
assert_eq!(U8F8::overflowing_from_str_octal("7165.4"), Ok((check, true)));
sourcepub const fn overflowing_from_str_hex(
src: &str,
) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
pub const fn overflowing_from_str_hex( src: &str, ) -> Result<(FixedU32<Frac>, bool), ParseFixedError>
Parses a string slice containing hexadecimal digits to return 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.
Rounding is to the nearest, with ties rounded to even.
§Examples
use fixed::types::U8F8;
let check = U8F8::from_bits(0xFFE);
assert_eq!(U8F8::overflowing_from_str_hex("F.FE"), Ok((check, false)));
assert_eq!(U8F8::overflowing_from_str_hex("C0F.FE"), Ok((check, true)));
sourcepub const fn frac(self) -> FixedU32<Frac>
pub const fn frac(self) -> FixedU32<Frac>
Returns the fractional part.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
// 0000.0100
let quarter = Fix::ONE / 4;
// 0010.0100
let two_and_quarter = quarter * 9;
assert_eq!(two_and_quarter.frac(), quarter);
sourcepub const fn round_to_zero(self) -> FixedU32<Frac>
pub const fn round_to_zero(self) -> FixedU32<Frac>
Rounds to the next integer towards 0.
Note that for unsigned numbers, this is equivalent to floor
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.1).round_to_zero(), Fix::from_num(2));
assert_eq!(Fix::from_num(2.9).round_to_zero(), Fix::from_num(2));
sourcepub const fn ceil(self) -> FixedU32<Frac>
pub const fn ceil(self) -> FixedU32<Frac>
Rounds to the next integer towards +∞.
§Panics
When debug assertions are enabled, panics if the result does not fit.
When debug assertions are not enabled, the wrapped result can be
returned, but it is not considered a breaking change if in the future
it panics; if wrapping is required use wrapping_ceil
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).ceil(), Fix::from_num(3));
sourcepub const fn floor(self) -> FixedU32<Frac>
pub const fn floor(self) -> FixedU32<Frac>
Rounds to the next integer towards −∞.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).floor(), Fix::from_num(2));
sourcepub const fn round(self) -> FixedU32<Frac>
pub const fn round(self) -> FixedU32<Frac>
Rounds to the nearest integer, with ties rounded away from zero.
§Panics
When debug assertions are enabled, panics if the result does not fit.
When debug assertions are not enabled, the wrapped result can be
returned, but it is not considered a breaking change if in the future
it panics; if wrapping is required use wrapping_round
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).round(), Fix::from_num(3));
sourcepub const fn round_ties_even(self) -> FixedU32<Frac>
pub const fn round_ties_even(self) -> FixedU32<Frac>
Rounds to the nearest integer, with ties rounded to even.
§Panics
When debug assertions are enabled, panics if the result does not fit.
When debug assertions are not enabled, the wrapped result can be
returned, but it is not considered a breaking change if in the future
it panics; if wrapping is required use wrapping_round_ties_even
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).round_ties_even(), Fix::from_num(2));
assert_eq!(Fix::from_num(3.5).round_ties_even(), Fix::from_num(4));
sourcepub const fn checked_ceil(self) -> Option<FixedU32<Frac>>
pub const fn checked_ceil(self) -> Option<FixedU32<Frac>>
sourcepub const fn checked_floor(self) -> Option<FixedU32<Frac>>
pub const fn checked_floor(self) -> Option<FixedU32<Frac>>
sourcepub const fn checked_round(self) -> Option<FixedU32<Frac>>
pub const fn checked_round(self) -> Option<FixedU32<Frac>>
Checked round. Rounds to the nearest integer, with ties
rounded away from zero, returning None
on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).checked_round(), Some(Fix::from_num(3)));
assert!(Fix::MAX.checked_round().is_none());
sourcepub const fn checked_round_ties_even(self) -> Option<FixedU32<Frac>>
pub const fn checked_round_ties_even(self) -> Option<FixedU32<Frac>>
Checked round. Rounds to the nearest integer, with ties rounded to
even, returning None
on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).checked_round_ties_even(), Some(Fix::from_num(2)));
assert_eq!(Fix::from_num(3.5).checked_round_ties_even(), Some(Fix::from_num(4)));
assert!(Fix::MAX.checked_round_ties_even().is_none());
sourcepub const fn saturating_ceil(self) -> FixedU32<Frac>
pub const fn saturating_ceil(self) -> FixedU32<Frac>
Saturating ceil. Rounds to the next integer towards +∞, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).saturating_ceil(), Fix::from_num(3));
assert_eq!(Fix::MAX.saturating_ceil(), Fix::MAX);
sourcepub const fn saturating_floor(self) -> FixedU32<Frac>
pub const fn saturating_floor(self) -> FixedU32<Frac>
Saturating floor. Rounds to the next integer towards −∞. Cannot overflow for unsigned values.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).saturating_floor(), Fix::from_num(2));
sourcepub const fn saturating_round(self) -> FixedU32<Frac>
pub const fn saturating_round(self) -> FixedU32<Frac>
Saturating round. Rounds to the nearest integer, with ties rounded away from zero, and saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).saturating_round(), Fix::from_num(3));
assert_eq!(Fix::MAX.saturating_round(), Fix::MAX);
sourcepub const fn saturating_round_ties_even(self) -> FixedU32<Frac>
pub const fn saturating_round_ties_even(self) -> FixedU32<Frac>
Saturating round. Rounds to the nearest integer, with ties rounded to even, and saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).saturating_round_ties_even(), Fix::from_num(2));
assert_eq!(Fix::from_num(3.5).saturating_round_ties_even(), Fix::from_num(4));
assert_eq!(Fix::MAX.saturating_round_ties_even(), Fix::MAX);
sourcepub const fn wrapping_ceil(self) -> FixedU32<Frac>
pub const fn wrapping_ceil(self) -> FixedU32<Frac>
Wrapping ceil. Rounds to the next integer towards +∞, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).wrapping_ceil(), Fix::from_num(3));
assert_eq!(Fix::MAX.wrapping_ceil(), Fix::MIN);
sourcepub const fn wrapping_floor(self) -> FixedU32<Frac>
pub const fn wrapping_floor(self) -> FixedU32<Frac>
Wrapping floor. Rounds to the next integer towards −∞. Cannot overflow for unsigned values.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).wrapping_floor(), Fix::from_num(2));
sourcepub const fn wrapping_round(self) -> FixedU32<Frac>
pub const fn wrapping_round(self) -> FixedU32<Frac>
Wrapping round. Rounds to the next integer to the nearest, with ties rounded away from zero, and wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).wrapping_round(), Fix::from_num(3));
assert_eq!(Fix::MAX.wrapping_round(), Fix::MIN);
sourcepub const fn wrapping_round_ties_even(self) -> FixedU32<Frac>
pub const fn wrapping_round_ties_even(self) -> FixedU32<Frac>
Wrapping round. Rounds to the next integer to the nearest, with ties rounded to even, and wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).wrapping_round_ties_even(), Fix::from_num(2));
assert_eq!(Fix::from_num(3.5).wrapping_round_ties_even(), Fix::from_num(4));
assert_eq!(Fix::MAX.wrapping_round_ties_even(), Fix::MIN);
sourcepub const fn unwrapped_ceil(self) -> FixedU32<Frac>
pub const fn unwrapped_ceil(self) -> FixedU32<Frac>
Unwrapped ceil. Rounds to the next integer towards +∞, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).unwrapped_ceil(), Fix::from_num(3));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_ceil();
sourcepub const fn unwrapped_floor(self) -> FixedU32<Frac>
pub const fn unwrapped_floor(self) -> FixedU32<Frac>
Unwrapped floor. Rounds to the next integer towards −∞. Cannot overflow for unsigned values.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).unwrapped_floor(), Fix::from_num(2));
sourcepub const fn unwrapped_round(self) -> FixedU32<Frac>
pub const fn unwrapped_round(self) -> FixedU32<Frac>
Unwrapped round. Rounds to the next integer to the nearest, with ties rounded away from zero, and panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).unwrapped_round(), Fix::from_num(3));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_round();
sourcepub const fn unwrapped_round_ties_even(self) -> FixedU32<Frac>
pub const fn unwrapped_round_ties_even(self) -> FixedU32<Frac>
Unwrapped round. Rounds to the next integer to the nearest, with ties rounded to even, and panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).unwrapped_round_ties_even(), Fix::from_num(2));
assert_eq!(Fix::from_num(3.5).unwrapped_round_ties_even(), Fix::from_num(4));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_round_ties_even();
sourcepub const fn overflowing_ceil(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_ceil(self) -> (FixedU32<Frac>, bool)
Overflowing ceil. Rounds to the next integer towards +∞.
Returns a tuple of the fixed-point number and a bool
, indicating
whether an overflow has occurred. On overflow, the wrapped value is
returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).overflowing_ceil(), (Fix::from_num(3), false));
assert_eq!(Fix::MAX.overflowing_ceil(), (Fix::MIN, true));
sourcepub const fn overflowing_floor(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_floor(self) -> (FixedU32<Frac>, bool)
sourcepub const fn overflowing_round(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_round(self) -> (FixedU32<Frac>, bool)
Overflowing round. Rounds to the next integer to the nearest, with ties rounded away from zero.
Returns a tuple of the fixed-point number and a bool
indicating
whether an overflow has occurred. On overflow, the wrapped value is
returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).overflowing_round(), (Fix::from_num(3), false));
assert_eq!(Fix::MAX.overflowing_round(), (Fix::MIN, true));
sourcepub const fn overflowing_round_ties_even(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_round_ties_even(self) -> (FixedU32<Frac>, bool)
Overflowing round. Rounds to the next integer to the nearest, with ties rounded to even.
Returns a tuple of the fixed-point number and a bool
indicating
whether an overflow has occurred. On overflow, the wrapped value is
returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2.5).overflowing_round_ties_even(), (Fix::from_num(2), false));
assert_eq!(Fix::from_num(3.5).overflowing_round_ties_even(), (Fix::from_num(4), false));
assert_eq!(Fix::MAX.overflowing_round_ties_even(), (Fix::MIN, true));
sourcepub const fn round_ties_to_even(self) -> FixedU32<Frac>
👎Deprecated since 1.28.0: renamed to round_ties_even
pub const fn round_ties_to_even(self) -> FixedU32<Frac>
round_ties_even
Rounds to the nearest integer, with ties rounded to even.
sourcepub const fn checked_round_ties_to_even(self) -> Option<FixedU32<Frac>>
👎Deprecated since 1.28.0: renamed to checked_round_ties_even
pub const fn checked_round_ties_to_even(self) -> Option<FixedU32<Frac>>
checked_round_ties_even
Checked round. Rounds to the nearest integer, with ties rounded to
even, returning None
on overflow.
sourcepub const fn saturating_round_ties_to_even(self) -> FixedU32<Frac>
👎Deprecated since 1.28.0: renamed to saturating_round_ties_even
pub const fn saturating_round_ties_to_even(self) -> FixedU32<Frac>
saturating_round_ties_even
Saturating round. Rounds to the nearest integer, with ties rounded to even, and saturating on overflow.
sourcepub const fn wrapping_round_ties_to_even(self) -> FixedU32<Frac>
👎Deprecated since 1.28.0: renamed to wrapping_round_ties_even
pub const fn wrapping_round_ties_to_even(self) -> FixedU32<Frac>
wrapping_round_ties_even
Wrapping round. Rounds to the next integer to the nearest, with ties rounded to even, and wrapping on overflow.
sourcepub const fn unwrapped_round_ties_to_even(self) -> FixedU32<Frac>
👎Deprecated since 1.28.0: renamed to unwrapped_round_ties_even
pub const fn unwrapped_round_ties_to_even(self) -> FixedU32<Frac>
unwrapped_round_ties_even
Unwrapped round. Rounds to the next integer to the nearest, with ties rounded to even, and panicking on overflow.
sourcepub const fn overflowing_round_ties_to_even(self) -> (FixedU32<Frac>, bool)
👎Deprecated since 1.28.0: renamed to overflowing_round_ties_even
pub const fn overflowing_round_ties_to_even(self) -> (FixedU32<Frac>, bool)
overflowing_round_ties_even
Overflowing round. Rounds to the next integer to the nearest, with ties rounded to even.
sourcepub const fn int_log2(self) -> i32
pub const fn int_log2(self) -> i32
Integer base-2 logarithm, rounded down.
§Panics
Panics if the fixed-point number is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(4).int_log2(), 2);
assert_eq!(Fix::from_num(3.9375).int_log2(), 1);
assert_eq!(Fix::from_num(0.25).int_log2(), -2);
assert_eq!(Fix::from_num(0.1875).int_log2(), -3);
sourcepub const fn int_log10(self) -> i32
pub const fn int_log10(self) -> i32
Integer base-10 logarithm, rounded down.
§Panics
Panics if the fixed-point number is zero.
§Examples
use fixed::{
types::extra::{U2, U6},
FixedU32,
};
assert_eq!(FixedU32::<U2>::from_num(10).int_log10(), 1);
assert_eq!(FixedU32::<U2>::from_num(9.75).int_log10(), 0);
assert_eq!(FixedU32::<U6>::from_num(0.109375).int_log10(), -1);
assert_eq!(FixedU32::<U6>::from_num(0.09375).int_log10(), -2);
sourcepub const fn int_log(self, base: u32) -> i32
pub const fn int_log(self, base: u32) -> i32
Integer logarithm to the specified base, rounded down.
§Panics
Panics if the fixed-point number is zero or if the base is < 2.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(4).int_log(2), 2);
assert_eq!(Fix::from_num(5.75).int_log(5), 1);
assert_eq!(Fix::from_num(0.25).int_log(5), -1);
assert_eq!(Fix::from_num(0.1875).int_log(5), -2);
sourcepub const fn checked_int_log2(self) -> Option<i32>
pub const fn checked_int_log2(self) -> Option<i32>
Checked integer base-2 logarithm, rounded down.
Returns the logarithm or None
if the fixed-point number is
zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.checked_int_log2(), None);
assert_eq!(Fix::from_num(4).checked_int_log2(), Some(2));
assert_eq!(Fix::from_num(3.9375).checked_int_log2(), Some(1));
assert_eq!(Fix::from_num(0.25).checked_int_log2(), Some(-2));
assert_eq!(Fix::from_num(0.1875).checked_int_log2(), Some(-3));
sourcepub const fn checked_int_log10(self) -> Option<i32>
pub const fn checked_int_log10(self) -> Option<i32>
Checked integer base-10 logarithm, rounded down.
Returns the logarithm or None
if the fixed-point number is
zero.
§Examples
use fixed::{
types::extra::{U2, U6},
FixedU32,
};
assert_eq!(FixedU32::<U2>::ZERO.checked_int_log10(), None);
assert_eq!(FixedU32::<U2>::from_num(10).checked_int_log10(), Some(1));
assert_eq!(FixedU32::<U2>::from_num(9.75).checked_int_log10(), Some(0));
assert_eq!(FixedU32::<U6>::from_num(0.109375).checked_int_log10(), Some(-1));
assert_eq!(FixedU32::<U6>::from_num(0.09375).checked_int_log10(), Some(-2));
sourcepub const fn checked_int_log(self, base: u32) -> Option<i32>
pub const fn checked_int_log(self, base: u32) -> Option<i32>
Checked integer logarithm to the specified base, rounded down.
Returns the logarithm, or None
if the fixed-point number is
zero
or if the base is < 2.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ZERO.checked_int_log(5), None);
assert_eq!(Fix::from_num(4).checked_int_log(2), Some(2));
assert_eq!(Fix::from_num(5.75).checked_int_log(5), Some(1));
assert_eq!(Fix::from_num(0.25).checked_int_log(5), Some(-1));
assert_eq!(Fix::from_num(0.1875).checked_int_log(5), Some(-2));
sourcepub const fn recip(self) -> FixedU32<Frac>
pub const fn recip(self) -> FixedU32<Frac>
Returns the reciprocal (inverse) of the fixed-point number, 1/self
.
§Panics
Panics if the fixed-point number is zero.
When debug assertions are enabled, this method also panics if the
reciprocal overflows. 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_recip
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).recip(), Fix::from_num(0.5));
sourcepub const fn div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Euclidean division.
§Panics
Panics if the divisor is zero.
When debug assertions are enabled, this method also panics if the
division overflows. 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_div_euclid
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).div_euclid(Fix::from_num(2)), Fix::from_num(3));
sourcepub const fn div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
sourcepub const fn add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> FixedU32<Frac>
pub const fn add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> FixedU32<Frac>
Adds self
to the product a
× b
.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
The mul_acc
method performs the same operation as this method but mutates
self
instead of returning the result.
§Panics
When debug assertions are enabled, this method panics if the result overflows.
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_add_prod
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).add_prod(Fix::from_num(4), Fix::from_num(0.5)), 5);
sourcepub fn mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
)
pub fn mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, )
Multiply and accumulate. Adds (a
× b
) to self
.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
The add_prod
method performs the same operation as this method but returns
the result instead of mutating self
.
§Panics
When debug assertions are enabled, this method panics if the result
overflows. 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_mul_acc
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
acc.mul_acc(Fix::from_num(4), Fix::from_num(0.5));
assert_eq!(acc, 5);
sourcepub const fn rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
sourcepub const fn sqrt(self) -> Self
pub const fn sqrt(self) -> Self
Returns the square root.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).sqrt(), Fix::SQRT_2);
sourcepub const fn lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> FixedU32<RangeFrac>
pub const fn lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> FixedU32<RangeFrac>
Linear interpolation between start
and end
.
Returns
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Panics
When debug assertions are enabled, this method panics if the result overflows.
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_lerp
instead.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let start = Fix::from_num(2);
let end = Fix::from_num(3.5);
assert_eq!(Fix::from_num(0.0).lerp(start, end), 2);
assert_eq!(Fix::from_num(0.5).lerp(start, end), 2.75);
assert_eq!(Fix::from_num(1.0).lerp(start, end), 3.5);
assert_eq!(Fix::from_num(2.0).lerp(start, end), 5);
sourcepub const fn checked_mul(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_mul(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
sourcepub const fn checked_div(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
pub const fn checked_div(self, rhs: FixedU32<Frac>) -> Option<FixedU32<Frac>>
sourcepub const fn checked_recip(self) -> Option<FixedU32<Frac>>
pub const fn checked_recip(self) -> Option<FixedU32<Frac>>
sourcepub const fn checked_div_euclid(
self,
rhs: FixedU32<Frac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_div_euclid( self, rhs: FixedU32<Frac>, ) -> Option<FixedU32<Frac>>
Checked Euclidean division. Returns the quotient, or
None
if the divisor is zero or on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).checked_div_euclid(Fix::from_num(2)), Some(Fix::from_num(3)));
assert_eq!(Fix::from_num(7.5).checked_div_euclid(Fix::ZERO), None);
assert_eq!(Fix::MAX.checked_div_euclid(Fix::from_num(0.25)), None);
sourcepub const fn checked_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> Option<FixedU32<Frac>>
pub const fn checked_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> Option<FixedU32<Frac>>
Adds self
to the product a
× b
, returning None
on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(3).checked_add_prod(Fix::from_num(4), Fix::from_num(0.5)),
Some(Fix::from_num(5))
);
assert_eq!(Fix::DELTA.checked_add_prod(Fix::MAX, Fix::ONE), None);
sourcepub fn checked_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> Option<()>
pub fn checked_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> Option<()>
Checked multiply and accumulate. Adds (a
× b
) to self
,
or returns None
on overflow.
Like all other checked methods, this method wraps the successful return value in
an Option
. Since the unchecked mul_acc
method does not return a value,
which is equivalent to returning ()
, this method wraps ()
into Some(())
on success.
When overflow occurs, self
is not modified and retains its previous value.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
let check = acc.checked_mul_acc(Fix::from_num(4), Fix::from_num(0.5));
assert_eq!(check, Some(()));
assert_eq!(acc, 5);
acc = Fix::DELTA;
let check = acc.checked_mul_acc(Fix::MAX, Fix::ONE);
assert_eq!(check, None);
// acc is unchanged on error
assert_eq!(acc, Fix::DELTA);
sourcepub const fn checked_rem_int(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_rem_int(self, rhs: u32) -> Option<FixedU32<Frac>>
Checked fixed-point remainder for division by an integer.
Returns the remainder, or None
if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3.75).checked_rem_int(2), Some(Fix::from_num(1.75)));
assert_eq!(Fix::from_num(3.75).checked_rem_int(0), None);
sourcepub const fn checked_div_euclid_int(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_div_euclid_int(self, rhs: u32) -> Option<FixedU32<Frac>>
Checked Euclidean division by an integer. Returns the
quotient, or None
if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).checked_div_euclid_int(2), Some(Fix::from_num(3)));
assert_eq!(Fix::from_num(7.5).checked_div_euclid_int(0), None);
sourcepub const fn checked_rem_euclid_int(self, rhs: u32) -> Option<FixedU32<Frac>>
pub const fn checked_rem_euclid_int(self, rhs: u32) -> Option<FixedU32<Frac>>
Checked remainder for Euclidean division by an integer.
Returns the remainder, or None
if the divisor is zero.
§Examples
use fixed::{types::extra::U28, FixedU32};
type Fix = FixedU32<U28>;
assert_eq!(Fix::from_num(7.5).checked_rem_euclid_int(2), Some(Fix::from_num(1.5)));
assert_eq!(Fix::from_num(7.5).checked_rem_euclid_int(0), None);
sourcepub const fn checked_sqrt(self) -> Option<Self>
pub const fn checked_sqrt(self) -> Option<Self>
Checked square root. Always returns the square root for unsigned numbers.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).checked_sqrt(), Some(Fix::SQRT_2));
sourcepub const fn checked_lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> Option<FixedU32<RangeFrac>>
pub const fn checked_lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> Option<FixedU32<RangeFrac>>
Checked linear interpolation between start
and end
. Returns
None
on overflow.
The interpolted value is
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(0.5).checked_lerp(Fix::ZERO, Fix::MAX), Some(Fix::MAX / 2));
assert_eq!(Fix::from_num(1.5).checked_lerp(Fix::ZERO, Fix::MAX), None);
sourcepub const fn saturating_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Saturating multiplication. Returns the product, saturating on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).saturating_mul(Fix::from_num(2)), Fix::from_num(6));
assert_eq!(Fix::MAX.saturating_mul(Fix::from_num(2)), Fix::MAX);
sourcepub const fn saturating_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Saturating division. Returns the quotient, saturating on overflow.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_half = Fix::ONE / 2;
assert_eq!(Fix::ONE.saturating_div(Fix::from_num(2)), one_half);
assert_eq!(Fix::MAX.saturating_div(one_half), Fix::MAX);
sourcepub const fn saturating_recip(self) -> FixedU32<Frac>
pub const fn saturating_recip(self) -> FixedU32<Frac>
sourcepub const fn saturating_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn saturating_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Saturating Euclidean division. Returns the quotient, saturating on overflow.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).saturating_div_euclid(Fix::from_num(2)), Fix::from_num(3));
assert_eq!(Fix::MAX.saturating_div_euclid(Fix::from_num(0.25)), Fix::MAX);
sourcepub const fn saturating_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn saturating_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
Saturating Euclidean division by an integer. Returns the quotient.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).saturating_div_euclid_int(2), Fix::from_num(3));
sourcepub const fn saturating_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> FixedU32<Frac>
pub const fn saturating_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> FixedU32<Frac>
Adds self
to the product a
× b
, saturating on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(3).saturating_add_prod(Fix::from_num(4), Fix::from_num(0.5)),
5
);
assert_eq!(Fix::ONE.saturating_add_prod(Fix::MAX, Fix::from_num(3)), Fix::MAX);
sourcepub fn saturating_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
)
pub fn saturating_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, )
Saturating multiply and accumulate. Adds (a
× b
) to self
,
saturating on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
acc.saturating_mul_acc(Fix::from_num(4), Fix::from_num(0.5));
assert_eq!(acc, 5);
acc = Fix::MAX / 2;
acc.saturating_mul_acc(Fix::MAX / 2, Fix::from_num(3));
assert_eq!(acc, Fix::MAX);
sourcepub const fn saturating_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn saturating_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
Saturating remainder for Euclidean division by an integer. Returns the remainder.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U28, FixedU32};
type Fix = FixedU32<U28>;
assert_eq!(Fix::from_num(7.5).saturating_rem_euclid_int(2), Fix::from_num(1.5));
sourcepub const fn saturating_sqrt(self) -> Self
pub const fn saturating_sqrt(self) -> Self
Returns the square root, saturating on overflow. Can never overflow for unsigned numbers.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).saturating_sqrt(), Fix::SQRT_2);
sourcepub const fn saturating_lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> FixedU32<RangeFrac>
pub const fn saturating_lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> FixedU32<RangeFrac>
Linear interpolation between start
and end
, saturating on
overflow.
The interpolated value is
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(0.5).saturating_lerp(Fix::ZERO, Fix::MAX), Fix::MAX / 2);
assert_eq!(Fix::from_num(1.5).saturating_lerp(Fix::ZERO, Fix::MAX), Fix::MAX);
assert_eq!(Fix::from_num(3.0).saturating_lerp(Fix::MAX, Fix::ZERO), Fix::ZERO);
sourcepub const fn wrapping_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping multiplication. Returns the product, wrapping on overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).wrapping_mul(Fix::from_num(2)), Fix::from_num(6));
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.wrapping_mul(Fix::from_num(4)), wrapped);
sourcepub const fn wrapping_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping division. Returns the quotient, wrapping on overflow.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).wrapping_div(Fix::from_num(2)), one_point_5);
let quarter = Fix::ONE / 4;
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.wrapping_div(quarter), wrapped);
sourcepub const fn wrapping_recip(self) -> FixedU32<Frac>
pub const fn wrapping_recip(self) -> FixedU32<Frac>
sourcepub const fn wrapping_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn wrapping_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Wrapping Euclidean division. Returns the quotient, wrapping on overflow.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).wrapping_div_euclid(Fix::from_num(2)), Fix::from_num(3));
let wrapped = Fix::MAX.wrapping_mul_int(4).round_to_zero();
assert_eq!(Fix::MAX.wrapping_div_euclid(Fix::from_num(0.25)), wrapped);
sourcepub const fn wrapping_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
sourcepub const fn wrapping_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> FixedU32<Frac>
pub const fn wrapping_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> FixedU32<Frac>
Adds self
to the product a
× b
, wrapping on overflow.
The a
and b
parameters can have a fixed-point type like self
but with a
different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(3).wrapping_add_prod(Fix::from_num(4), Fix::from_num(0.5)),
5
);
assert_eq!(
Fix::MAX.wrapping_add_prod(Fix::MAX, Fix::from_num(3)),
Fix::MAX.wrapping_mul_int(4)
);
sourcepub fn wrapping_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
)
pub fn wrapping_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, )
Wrapping multiply and accumulate. Adds (a
× b
) to self
,
wrapping on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
acc.wrapping_mul_acc(Fix::from_num(4), Fix::from_num(0.5));
assert_eq!(acc, 5);
acc = Fix::MAX;
acc.wrapping_mul_acc(Fix::MAX, Fix::from_num(3));
assert_eq!(acc, Fix::MAX.wrapping_mul_int(4));
sourcepub const fn wrapping_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn wrapping_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
Wrapping remainder for Euclidean division by an integer. Returns the remainder.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U28, FixedU32};
type Fix = FixedU32<U28>;
assert_eq!(Fix::from_num(7.5).wrapping_rem_euclid_int(2), Fix::from_num(1.5));
sourcepub const fn wrapping_sqrt(self) -> Self
pub const fn wrapping_sqrt(self) -> Self
Returns the square root, wrapping on overflow. Can never overflow for unsigned numbers.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).wrapping_sqrt(), Fix::SQRT_2);
sourcepub const fn wrapping_lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> FixedU32<RangeFrac>
pub const fn wrapping_lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> FixedU32<RangeFrac>
Linear interpolation between start
and end
, wrapping on
overflow.
The interpolated value is
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(0.5).wrapping_lerp(Fix::ZERO, Fix::MAX), Fix::MAX / 2);
assert_eq!(
Fix::from_num(1.5).wrapping_lerp(Fix::ZERO, Fix::MAX),
Fix::MAX.wrapping_add(Fix::MAX / 2)
);
sourcepub const fn unwrapped_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_mul(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped multiplication. Returns the product, panicking on overflow.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).unwrapped_mul(Fix::from_num(2)), Fix::from_num(6));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_mul(Fix::from_num(4));
sourcepub const fn unwrapped_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_div(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped division. Returns the quotient, panicking on overflow.
§Panics
Panics if the divisor is zero or if the division results in overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).unwrapped_div(Fix::from_num(2)), one_point_5);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let quarter = Fix::ONE / 4;
let _overflow = Fix::MAX.unwrapped_div(quarter);
sourcepub const fn unwrapped_recip(self) -> FixedU32<Frac>
pub const fn unwrapped_recip(self) -> FixedU32<Frac>
sourcepub const fn unwrapped_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
pub const fn unwrapped_div_euclid(self, rhs: FixedU32<Frac>) -> FixedU32<Frac>
Unwrapped Euclidean division. Returns the quotient, panicking on overflow.
§Panics
Panics if the divisor is zero or if the division results in overflow.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).unwrapped_div_euclid(Fix::from_num(2)), Fix::from_num(3));
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::MAX.unwrapped_div_euclid(Fix::from_num(0.25));
sourcepub const fn unwrapped_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> FixedU32<Frac>
pub const fn unwrapped_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> FixedU32<Frac>
Adds self
to the product a
× b
, panicking on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(3).unwrapped_add_prod(Fix::from_num(4), Fix::from_num(0.5)),
5
);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::DELTA.unwrapped_add_prod(Fix::MAX, Fix::ONE);
sourcepub fn unwrapped_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
)
pub fn unwrapped_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, )
Unwrapped multiply and accumulate. Adds (a
× b
) to self
,
panicking on overflow.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Panics
Panics if the result does not fit.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
acc.unwrapped_mul_acc(Fix::from_num(4), Fix::from_num(0.5));
assert_eq!(acc, 5);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::DELTA;
acc.unwrapped_mul_acc(Fix::MAX, Fix::ONE);
sourcepub const fn unwrapped_rem_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_rem_int(self, rhs: u32) -> FixedU32<Frac>
Unwrapped fixed-point remainder for division by an integer. Returns the remainder, panicking if the divisor is zero.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3.75).unwrapped_rem_int(2), Fix::from_num(1.75));
The following panics because the divisor is zero.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _divisor_is_zero = Fix::from_num(3.75).unwrapped_rem_int(0);
sourcepub const fn unwrapped_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_div_euclid_int(self, rhs: u32) -> FixedU32<Frac>
sourcepub const fn unwrapped_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
pub const fn unwrapped_rem_euclid_int(self, rhs: u32) -> FixedU32<Frac>
Unwrapped remainder for Euclidean division by an integer. Returns the remainder.
Can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U28, FixedU32};
type Fix = FixedU32<U28>;
assert_eq!(Fix::from_num(7.5).unwrapped_rem_euclid_int(2), Fix::from_num(1.5));
sourcepub const fn unwrapped_sqrt(self) -> Self
pub const fn unwrapped_sqrt(self) -> Self
Returns the square root. Can never overflow for unsigned numbers.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(2).unwrapped_sqrt(), Fix::SQRT_2);
sourcepub const fn unwrapped_lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> FixedU32<RangeFrac>
pub const fn unwrapped_lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> FixedU32<RangeFrac>
Linear interpolation between start
and end
, panicking on
overflow.
The interpolated value is
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Panics
Panics if the result overflows.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(0.5).unwrapped_lerp(Fix::ZERO, Fix::MAX), Fix::MAX / 2);
The following panics because of overflow.
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let _overflow = Fix::from_num(1.5).unwrapped_lerp(Fix::ZERO, Fix::MAX);
sourcepub const fn overflowing_mul(
self,
rhs: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_mul( self, rhs: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing multiplication.
Returns a tuple of the product and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(3).overflowing_mul(Fix::from_num(2)), (Fix::from_num(6), false));
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.overflowing_mul(Fix::from_num(4)), (wrapped, true));
sourcepub const fn overflowing_div(
self,
rhs: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_div( self, rhs: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing division.
Returns a tuple of the quotient and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let one_point_5 = Fix::from_bits(0b11 << (4 - 1));
assert_eq!(Fix::from_num(3).overflowing_div(Fix::from_num(2)), (one_point_5, false));
let quarter = Fix::ONE / 4;
let wrapped = Fix::from_bits(!0 << 2);
assert_eq!(Fix::MAX.overflowing_div(quarter), (wrapped, true));
sourcepub const fn overflowing_recip(self) -> (FixedU32<Frac>, bool)
pub const fn overflowing_recip(self) -> (FixedU32<Frac>, bool)
Overflowing reciprocal.
Returns a tuple of the reciprocal and a bool
indicating whether
an overflow has occurred. On overflow, the wrapped value is returned.
§Panics
Panics if the fixed-point number is zero.
§Examples
use fixed::{
types::extra::{U4, U31},
FixedU32,
};
type Fix = FixedU32<U4>;
// only one integer bit
type Small = FixedU32<U31>;
assert_eq!(Fix::from_num(0.25).overflowing_recip(), (Fix::from_num(4), false));
assert_eq!(Small::from_num(0.25).overflowing_recip(), (Small::ZERO, true));
sourcepub const fn overflowing_div_euclid(
self,
rhs: FixedU32<Frac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_div_euclid( self, rhs: FixedU32<Frac>, ) -> (FixedU32<Frac>, bool)
Overflowing Euclidean division.
Returns a tuple of the quotient and a bool
indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let check = Fix::from_num(3);
assert_eq!(Fix::from_num(7.5).overflowing_div_euclid(Fix::from_num(2)), (check, false));
let wrapped = Fix::MAX.wrapping_mul_int(4).round_to_zero();
assert_eq!(Fix::MAX.overflowing_div_euclid(Fix::from_num(0.25)), (wrapped, true));
sourcepub const fn overflowing_div_euclid_int(
self,
rhs: u32,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_div_euclid_int( self, rhs: u32, ) -> (FixedU32<Frac>, bool)
Overflowing Euclidean division by an integer.
Returns a tuple of the quotient and false
, as the division can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::from_num(7.5).overflowing_div_euclid_int(2), (Fix::from_num(3), false));
sourcepub const fn overflowing_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>(
self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_add_prod<AFrac: LeEqU32, BFrac: LeEqU32>( self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> (FixedU32<Frac>, bool)
Adds self
to the product a
× b
.
Returns a tuple of the result and a bool
indicating whether an overflow
has occurred. On overflow, the wrapped value is returned.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(3).overflowing_add_prod(Fix::from_num(4), Fix::from_num(0.5)),
(Fix::from_num(5), false)
);
assert_eq!(
Fix::MAX.overflowing_add_prod(Fix::MAX, Fix::from_num(3)),
(Fix::MAX.wrapping_mul_int(4), true)
);
sourcepub fn overflowing_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>(
&mut self,
a: FixedU32<AFrac>,
b: FixedU32<BFrac>,
) -> bool
pub fn overflowing_mul_acc<AFrac: LeEqU32, BFrac: LeEqU32>( &mut self, a: FixedU32<AFrac>, b: FixedU32<BFrac>, ) -> bool
Overflowing multiply and accumulate. Adds (a
× b
) to self
,
wrapping and returning true
if overflow occurs.
The a
and b
parameters can have a fixed-point type like
self
but with a different number of fractional bits.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
let mut acc = Fix::from_num(3);
assert!(!acc.overflowing_mul_acc(Fix::from_num(4), Fix::from_num(0.5)));
assert_eq!(acc, 5);
acc = Fix::MAX;
assert!(acc.overflowing_mul_acc(Fix::MAX, Fix::from_num(3)));
assert_eq!(acc, Fix::MAX.wrapping_mul_int(4));
sourcepub const fn overflowing_rem_euclid_int(
self,
rhs: u32,
) -> (FixedU32<Frac>, bool)
pub const fn overflowing_rem_euclid_int( self, rhs: u32, ) -> (FixedU32<Frac>, bool)
Remainder for Euclidean division by an integer.
Returns a tuple of the remainder and false
, as this can never overflow for unsigned values.
§Panics
Panics if the divisor is zero.
§Examples
use fixed::{types::extra::U28, FixedU32};
type Fix = FixedU32<U28>;
assert_eq!(Fix::from_num(7.5).overflowing_rem_euclid_int(2), (Fix::from_num(1.5), false));
sourcepub const fn overflowing_sqrt(self) -> (Self, bool)
pub const fn overflowing_sqrt(self) -> (Self, bool)
Returns the square root.
Returns a tuple of the result and false
, since this can never overflow for unsigned numbers.
This method uses an iterative method, with up to 32 iterations for
FixedU32
. The result is rounded down, and the error is
< DELTA
. That is,
result ≤ √self
< result + DELTA
.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(2).overflowing_sqrt(),
(Fix::SQRT_2, false)
);
sourcepub const fn overflowing_lerp<RangeFrac>(
self,
start: FixedU32<RangeFrac>,
end: FixedU32<RangeFrac>,
) -> (FixedU32<RangeFrac>, bool)
pub const fn overflowing_lerp<RangeFrac>( self, start: FixedU32<RangeFrac>, end: FixedU32<RangeFrac>, ) -> (FixedU32<RangeFrac>, bool)
Overflowing linear interpolation between start
and end
.
Returns a tuple of the result and a bool
indicationg whether an overflow
has occurred. On overflow, the wrapped value is returned.
The interpolated value is
start
+ self
× (end
− start
). This
is start
when self
= 0, end
when self
= 1, and
linear interpolation for all other values of self
. Linear extrapolation is
performed if self
is not in the range 0 ≤ x ≤ 1.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(
Fix::from_num(0.5).overflowing_lerp(Fix::ZERO, Fix::MAX),
(Fix::MAX / 2, false)
);
assert_eq!(
Fix::from_num(1.5).overflowing_lerp(Fix::ZERO, Fix::MAX),
(Fix::MAX.wrapping_add(Fix::MAX / 2), true)
);
source§impl<Frac: LeEqU32> FixedU32<Frac>
impl<Frac: LeEqU32> FixedU32<Frac>
This block contains constants in the range 0 < x < 0.5.
§Examples
use fixed::{consts, types::extra::U32, FixedU32};
type Fix = FixedU32<U32>;
assert_eq!(Fix::LOG10_2, Fix::from_num(consts::LOG10_2));
sourcepub const FRAC_1_TAU: FixedU32<Frac> = _
pub const FRAC_1_TAU: FixedU32<Frac> = _
1/τ = 0.159154…
sourcepub const FRAC_2_TAU: FixedU32<Frac> = _
pub const FRAC_2_TAU: FixedU32<Frac> = _
2/τ = 0.318309…
sourcepub const FRAC_1_SQRT_2PI: FixedU32<Frac> = _
pub const FRAC_1_SQRT_2PI: FixedU32<Frac> = _
1/√2π = 0.398942…
source§impl<Frac> FixedU32<Frac>
impl<Frac> FixedU32<Frac>
This block contains constants in the range 0.5 ≤ x < 1.
§Examples
use fixed::{consts, types::extra::U32, FixedU32};
type Fix = FixedU32<U32>;
assert_eq!(Fix::LN_2, Fix::from_num(consts::LN_2));
assert!(0.5 <= Fix::LN_2 && Fix::LN_2 < 1);
sourcepub const FRAC_TAU_8: FixedU32<Frac> = _
pub const FRAC_TAU_8: FixedU32<Frac> = _
τ/8 = 0.785398…
sourcepub const FRAC_TAU_12: FixedU32<Frac> = _
pub const FRAC_TAU_12: FixedU32<Frac> = _
τ/12 = 0.523598…
sourcepub const FRAC_4_TAU: FixedU32<Frac> = _
pub const FRAC_4_TAU: FixedU32<Frac> = _
4/τ = 0.636619…
sourcepub const FRAC_1_SQRT_PI: FixedU32<Frac> = _
pub const FRAC_1_SQRT_PI: FixedU32<Frac> = _
1/√π = 0.564189…
sourcepub const FRAC_1_SQRT_2: FixedU32<Frac> = _
pub const FRAC_1_SQRT_2: FixedU32<Frac> = _
1/√2 = 0.707106…
sourcepub const FRAC_1_SQRT_3: FixedU32<Frac> = _
pub const FRAC_1_SQRT_3: FixedU32<Frac> = _
1/√3 = 0.577350…
sourcepub const FRAC_1_PHI: FixedU32<Frac> = _
pub const FRAC_1_PHI: FixedU32<Frac> = _
The golden ratio conjugate, Φ = 1/φ = 0.618033…
source§impl<Frac> FixedU32<Frac>
impl<Frac> FixedU32<Frac>
This block contains constants in the range 1 ≤ x < 2.
These constants are not representable in unsigned fixed-point numbers with less than 1 integer bit.
§Examples
use fixed::{consts, types::extra::U31, FixedU32};
type Fix = FixedU32<U31>;
assert_eq!(Fix::LOG2_E, Fix::from_num(consts::LOG2_E));
assert!(1 <= Fix::LOG2_E && Fix::LOG2_E < 2);
The following example fails to compile, since the maximum representable value with 32 fractional bits and 0 integer bits is < 1.
use fixed::{consts, types::extra::U32, FixedU32};
type Fix = FixedU32<U32>;
let _ = Fix::LOG2_E;
sourcepub const ONE: FixedU32<Frac> = _
pub const ONE: FixedU32<Frac> = _
One.
§Examples
use fixed::{types::extra::U4, FixedU32};
type Fix = FixedU32<U4>;
assert_eq!(Fix::ONE, Fix::from_num(1));
sourcepub const FRAC_TAU_4: FixedU32<Frac> = _
pub const FRAC_TAU_4: FixedU32<Frac> = _
τ/4 = 1.57079…
sourcepub const FRAC_TAU_6: FixedU32<Frac> = _
pub const FRAC_TAU_6: FixedU32<Frac> = _
τ/6 = 1.04719…
sourcepub const FRAC_2_SQRT_PI: FixedU32<Frac> = _
pub const FRAC_2_SQRT_PI: FixedU32<Frac> = _
2/√π = 1.12837…
source§impl<Frac> FixedU32<Frac>
impl<Frac> FixedU32<Frac>
This block contains constants in the range 2 ≤ x < 4.
These constants are not representable in unsigned fixed-point numbers with less than 2 integer bits.
§Examples
use fixed::{consts, types::extra::U30, FixedU32};
type Fix = FixedU32<U30>;
assert_eq!(Fix::E, Fix::from_num(consts::E));
assert!(2 <= Fix::E && Fix::E < 4);
The following example fails to compile, since the maximum representable value with 31 fractional bits and 1 integer bit is < 2.
use fixed::{consts, types::extra::U31, FixedU32};
type Fix = FixedU32<U31>;
let _ = Fix::E;
sourcepub const FRAC_TAU_2: FixedU32<Frac> = _
pub const FRAC_TAU_2: FixedU32<Frac> = _
τ/2 = 3.14159…
sourcepub const FRAC_TAU_3: FixedU32<Frac> = _
pub const FRAC_TAU_3: FixedU32<Frac> = _
τ/3 = 2.09439…
source§impl<Frac> FixedU32<Frac>
impl<Frac> FixedU32<Frac>
This block contains constants in the range 4 ≤ x < 8.
These constants are not representable in unsigned fixed-point numbers with less than 3 integer bits.
§Examples
use fixed::{consts, types::extra::U29, FixedU32};
type Fix = FixedU32<U29>;
assert_eq!(Fix::TAU, Fix::from_num(consts::TAU));
assert!(4 <= Fix::TAU && Fix::TAU < 8);
The following example fails to compile, since the maximum representable value with 30 fractional bits and 2 integer bits is < 4.
use fixed::{consts, types::extra::U30, FixedU32};
type Fix = FixedU32<U30>;
let _ = Fix::TAU;
Trait Implementations§
source§impl<Frac> AddAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> AddAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn add_assign(&mut self, rhs: &FixedU32<Frac>)
fn add_assign(&mut self, rhs: &FixedU32<Frac>)
+=
operation. Read moresource§impl<Frac> AddAssign for FixedU32<Frac>
impl<Frac> AddAssign for FixedU32<Frac>
source§fn add_assign(&mut self, rhs: FixedU32<Frac>)
fn add_assign(&mut self, rhs: FixedU32<Frac>)
+=
operation. Read moresource§impl<'a, Frac> Arbitrary<'a> for FixedU32<Frac>
impl<'a, Frac> Arbitrary<'a> for FixedU32<Frac>
source§fn arbitrary(u: &mut Unstructured<'a>) -> ArbitraryResult<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> ArbitraryResult<Self>
Self
from the given unstructured data. Read moresource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moresource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moresource§impl<Frac> BitAndAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> BitAndAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn bitand_assign(&mut self, rhs: &FixedU32<Frac>)
fn bitand_assign(&mut self, rhs: &FixedU32<Frac>)
&=
operation. Read moresource§impl<Frac> BitAndAssign for FixedU32<Frac>
impl<Frac> BitAndAssign for FixedU32<Frac>
source§fn bitand_assign(&mut self, rhs: FixedU32<Frac>)
fn bitand_assign(&mut self, rhs: FixedU32<Frac>)
&=
operation. Read moresource§impl<Frac> BitOrAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> BitOrAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn bitor_assign(&mut self, rhs: &FixedU32<Frac>)
fn bitor_assign(&mut self, rhs: &FixedU32<Frac>)
|=
operation. Read moresource§impl<Frac> BitOrAssign for FixedU32<Frac>
impl<Frac> BitOrAssign for FixedU32<Frac>
source§fn bitor_assign(&mut self, rhs: FixedU32<Frac>)
fn bitor_assign(&mut self, rhs: FixedU32<Frac>)
|=
operation. Read moresource§impl<Frac> BitXorAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> BitXorAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn bitxor_assign(&mut self, rhs: &FixedU32<Frac>)
fn bitxor_assign(&mut self, rhs: &FixedU32<Frac>)
^=
operation. Read moresource§impl<Frac> BitXorAssign for FixedU32<Frac>
impl<Frac> BitXorAssign for FixedU32<Frac>
source§fn bitxor_assign(&mut self, rhs: FixedU32<Frac>)
fn bitxor_assign(&mut self, rhs: FixedU32<Frac>)
^=
operation. Read moresource§impl<Frac> BorshDeserialize for FixedU32<Frac>
impl<Frac> BorshDeserialize for FixedU32<Frac>
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl<Frac> BorshSerialize for FixedU32<Frac>
impl<Frac> BorshSerialize for FixedU32<Frac>
source§impl<Frac> CheckedAdd for FixedU32<Frac>
impl<Frac> CheckedAdd for FixedU32<Frac>
source§fn checked_add(&self, v: &Self) -> Option<Self>
fn checked_add(&self, v: &Self) -> Option<Self>
None
is
returned.source§impl<Frac: LeEqU32> CheckedCast<F128> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<F128> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<F128>
fn checked_cast(self) -> Option<F128>
source§impl<Frac: LeEqU32> CheckedCast<F128Bits> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<F128Bits> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<F128Bits>
fn checked_cast(self) -> Option<F128Bits>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> CheckedCast<FixedI128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> CheckedCast<FixedI128<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedI128<FracDst>>
fn checked_cast(self) -> Option<FixedI128<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> CheckedCast<FixedI16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> CheckedCast<FixedI16<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedI16<FracDst>>
fn checked_cast(self) -> Option<FixedI16<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedI32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedI32<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedI32<FracDst>>
fn checked_cast(self) -> Option<FixedI32<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> CheckedCast<FixedI64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> CheckedCast<FixedI64<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedI64<FracDst>>
fn checked_cast(self) -> Option<FixedI64<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> CheckedCast<FixedI8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> CheckedCast<FixedI8<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedI8<FracDst>>
fn checked_cast(self) -> Option<FixedI8<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> CheckedCast<FixedU128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> CheckedCast<FixedU128<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU128<FracDst>>
fn checked_cast(self) -> Option<FixedU128<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> CheckedCast<FixedU16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> CheckedCast<FixedU16<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU16<FracDst>>
fn checked_cast(self) -> Option<FixedU16<FracDst>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for F128
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for F128Bits
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for half_bf16
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for bool
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for bool
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for half_f16
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for f32
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for f64
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i128
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i128
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i16
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i16
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i32
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i32
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i64
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i64
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i8
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for i8
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for isize
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for isize
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u128
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u128
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u16
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u16
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u32
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u32
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u64
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u64
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u8
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for u8
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for usize
impl<Frac: LeEqU32> CheckedCast<FixedU32<Frac>> for usize
source§fn checked_cast(self) -> Option<FixedU32<Frac>>
fn checked_cast(self) -> Option<FixedU32<Frac>>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI128<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI16<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI64<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedI8<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU128<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU16<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU64<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> CheckedCast<FixedU32<FracDst>> for FixedU8<FracSrc>
source§fn checked_cast(self) -> Option<FixedU32<FracDst>>
fn checked_cast(self) -> Option<FixedU32<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> CheckedCast<FixedU64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> CheckedCast<FixedU64<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU64<FracDst>>
fn checked_cast(self) -> Option<FixedU64<FracDst>>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> CheckedCast<FixedU8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> CheckedCast<FixedU8<FracDst>> for FixedU32<FracSrc>
source§fn checked_cast(self) -> Option<FixedU8<FracDst>>
fn checked_cast(self) -> Option<FixedU8<FracDst>>
source§impl<Frac: LeEqU32> CheckedCast<bf16> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<bf16> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<half_bf16>
fn checked_cast(self) -> Option<half_bf16>
source§impl<Frac: LeEqU32> CheckedCast<f16> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<f16> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<half_f16>
fn checked_cast(self) -> Option<half_f16>
source§impl<Frac: LeEqU32> CheckedCast<f32> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<f32> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<f32>
fn checked_cast(self) -> Option<f32>
source§impl<Frac: LeEqU32> CheckedCast<f64> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<f64> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<f64>
fn checked_cast(self) -> Option<f64>
source§impl<Frac: LeEqU32> CheckedCast<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<i128> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<i128>
fn checked_cast(self) -> Option<i128>
source§impl<Frac: LeEqU32> CheckedCast<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<i16> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<i16>
fn checked_cast(self) -> Option<i16>
source§impl<Frac: LeEqU32> CheckedCast<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<i32> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<i32>
fn checked_cast(self) -> Option<i32>
source§impl<Frac: LeEqU32> CheckedCast<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<i64> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<i64>
fn checked_cast(self) -> Option<i64>
source§impl<Frac: LeEqU32> CheckedCast<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<i8> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<i8>
fn checked_cast(self) -> Option<i8>
source§impl<Frac: LeEqU32> CheckedCast<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<isize> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<isize>
fn checked_cast(self) -> Option<isize>
source§impl<Frac: LeEqU32> CheckedCast<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<u128> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<u128>
fn checked_cast(self) -> Option<u128>
source§impl<Frac: LeEqU32> CheckedCast<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<u16> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<u16>
fn checked_cast(self) -> Option<u16>
source§impl<Frac: LeEqU32> CheckedCast<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<u32> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<u32>
fn checked_cast(self) -> Option<u32>
source§impl<Frac: LeEqU32> CheckedCast<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<u64> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<u64>
fn checked_cast(self) -> Option<u64>
source§impl<Frac: LeEqU32> CheckedCast<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<u8> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<u8>
fn checked_cast(self) -> Option<u8>
source§impl<Frac: LeEqU32> CheckedCast<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedCast<usize> for FixedU32<Frac>
source§fn checked_cast(self) -> Option<usize>
fn checked_cast(self) -> Option<usize>
source§impl<Frac: LeEqU32> CheckedDiv for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedDiv for FixedU32<Frac>
source§fn checked_div(&self, v: &Self) -> Option<Self>
fn checked_div(&self, v: &Self) -> Option<Self>
None
is returned.source§impl<Frac: LeEqU32> CheckedMul for FixedU32<Frac>
impl<Frac: LeEqU32> CheckedMul for FixedU32<Frac>
source§fn checked_mul(&self, v: &Self) -> Option<Self>
fn checked_mul(&self, v: &Self) -> Option<Self>
None
is returned.source§impl<Frac> CheckedNeg for FixedU32<Frac>
impl<Frac> CheckedNeg for FixedU32<Frac>
source§fn checked_neg(&self) -> Option<Self>
fn checked_neg(&self) -> Option<Self>
None
for results that can’t be represented, like signed MIN
values that can’t be positive, or non-zero unsigned values that can’t be negative. Read moresource§impl<Frac> CheckedRem for FixedU32<Frac>
impl<Frac> CheckedRem for FixedU32<Frac>
source§impl<Frac> CheckedShl for FixedU32<Frac>
impl<Frac> CheckedShl for FixedU32<Frac>
source§impl<Frac> CheckedShr for FixedU32<Frac>
impl<Frac> CheckedShr for FixedU32<Frac>
source§impl<Frac> CheckedSub for FixedU32<Frac>
impl<Frac> CheckedSub for FixedU32<Frac>
source§fn checked_sub(&self, v: &Self) -> Option<Self>
fn checked_sub(&self, v: &Self) -> Option<Self>
None
is returned.source§impl<Frac: 'static> Contiguous for FixedU32<Frac>
impl<Frac: 'static> Contiguous for FixedU32<Frac>
source§const MAX_VALUE: u32 = 4_294_967_295u32
const MAX_VALUE: u32 = 4_294_967_295u32
source§fn from_integer(value: Self::Int) -> Option<Self>
fn from_integer(value: Self::Int) -> Option<Self>
value
is within the range for valid instances of this type,
returns Some(converted_value)
, otherwise, returns None
. Read moresource§fn into_integer(self) -> Self::Int
fn into_integer(self) -> Self::Int
C
into the underlying integral type. This
mostly exists otherwise generic code would need unsafe for the value as integer
Read moresource§impl<'de, Frac: LeEqU32> Deserialize<'de> for FixedU32<Frac>
impl<'de, Frac: LeEqU32> Deserialize<'de> for FixedU32<Frac>
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl<Frac: LeEqU32> DivAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac: LeEqU32> DivAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: &FixedU32<Frac>)
fn div_assign(&mut self, rhs: &FixedU32<Frac>)
/=
operation. Read moresource§impl<Frac> DivAssign<&NonZero<u32>> for FixedU32<Frac>
impl<Frac> DivAssign<&NonZero<u32>> for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: &NonZeroU32)
fn div_assign(&mut self, rhs: &NonZeroU32)
/=
operation. Read moresource§impl<Frac: LeEqU32> DivAssign<&u32> for FixedU32<Frac>
impl<Frac: LeEqU32> DivAssign<&u32> for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: &u32)
fn div_assign(&mut self, rhs: &u32)
/=
operation. Read moresource§impl<Frac> DivAssign<NonZero<u32>> for FixedU32<Frac>
impl<Frac> DivAssign<NonZero<u32>> for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: NonZeroU32)
fn div_assign(&mut self, rhs: NonZeroU32)
/=
operation. Read moresource§impl<Frac: LeEqU32> DivAssign<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> DivAssign<u32> for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
/=
operation. Read moresource§impl<Frac: LeEqU32> DivAssign for FixedU32<Frac>
impl<Frac: LeEqU32> DivAssign for FixedU32<Frac>
source§fn div_assign(&mut self, rhs: FixedU32<Frac>)
fn div_assign(&mut self, rhs: FixedU32<Frac>)
/=
operation. Read moresource§impl<Frac: LeEqU32> Fixed for FixedU32<Frac>
impl<Frac: LeEqU32> Fixed for FixedU32<Frac>
§type Frac = Frac
type Frac = Frac
Unsigned
as provided
by the typenum crate. Read more§type Signed = FixedI32<Frac>
type Signed = FixedI32<Frac>
Self
. Read more§type Unsigned = FixedU32<Frac>
type Unsigned = FixedU32<Frac>
Self
. Read moresource§const TRY_ONE: Option<Self> = Self::TRY_ONE
const TRY_ONE: Option<Self> = Self::TRY_ONE
None
.source§const DELTA: Self = Self::DELTA
const DELTA: Self = Self::DELTA
source§const FRAC_NBITS: u32 = Self::FRAC_NBITS
const FRAC_NBITS: u32 = Self::FRAC_NBITS
source§fn from_bits(bits: Self::Bits) -> Self
fn from_bits(bits: Self::Bits) -> Self
source§fn to_bits(self) -> Self::Bits
fn to_bits(self) -> Self::Bits
source§fn from_be(fixed: Self) -> Self
fn from_be(fixed: Self) -> Self
source§fn from_le(fixed: Self) -> Self
fn from_le(fixed: Self) -> Self
source§fn to_be(self) -> Self
fn to_be(self) -> Self
source§fn to_le(self) -> Self
fn to_le(self) -> Self
source§fn swap_bytes(self) -> Self
fn swap_bytes(self) -> Self
source§fn from_be_bytes(bits: Self::Bytes) -> Self
fn from_be_bytes(bits: Self::Bytes) -> Self
source§fn from_le_bytes(bits: Self::Bytes) -> Self
fn from_le_bytes(bits: Self::Bytes) -> Self
source§fn from_ne_bytes(bits: Self::Bytes) -> Self
fn from_ne_bytes(bits: Self::Bytes) -> Self
source§fn to_be_bytes(self) -> Self::Bytes
fn to_be_bytes(self) -> Self::Bytes
source§fn to_le_bytes(self) -> Self::Bytes
fn to_le_bytes(self) -> Self::Bytes
source§fn to_ne_bytes(self) -> Self::Bytes
fn to_ne_bytes(self) -> Self::Bytes
source§fn from_num<Src: ToFixed>(src: Src) -> Self
fn from_num<Src: ToFixed>(src: Src) -> Self
source§fn to_num<Dst: FromFixed>(self) -> Dst
fn to_num<Dst: FromFixed>(self) -> Dst
source§fn checked_from_num<Src: ToFixed>(val: Src) -> Option<Self>
fn checked_from_num<Src: ToFixed>(val: Src) -> Option<Self>
source§fn checked_to_num<Dst: FromFixed>(self) -> Option<Dst>
fn checked_to_num<Dst: FromFixed>(self) -> Option<Dst>
source§fn saturating_from_num<Src: ToFixed>(val: Src) -> Self
fn saturating_from_num<Src: ToFixed>(val: Src) -> Self
source§fn saturating_to_num<Dst: FromFixed>(self) -> Dst
fn saturating_to_num<Dst: FromFixed>(self) -> Dst
source§fn wrapping_from_num<Src: ToFixed>(val: Src) -> Self
fn wrapping_from_num<Src: ToFixed>(val: Src) -> Self
source§fn wrapping_to_num<Dst: FromFixed>(self) -> Dst
fn wrapping_to_num<Dst: FromFixed>(self) -> Dst
source§fn unwrapped_from_num<Src: ToFixed>(val: Src) -> Self
fn unwrapped_from_num<Src: ToFixed>(val: Src) -> Self
source§fn unwrapped_to_num<Dst: FromFixed>(self) -> Dst
fn unwrapped_to_num<Dst: FromFixed>(self) -> Dst
source§fn overflowing_from_num<Src: ToFixed>(val: Src) -> (Self, bool)
fn overflowing_from_num<Src: ToFixed>(val: Src) -> (Self, bool)
source§fn overflowing_to_num<Dst: FromFixed>(self) -> (Dst, bool)
fn overflowing_to_num<Dst: FromFixed>(self) -> (Dst, bool)
source§fn from_str_binary(src: &str) -> Result<Self, ParseFixedError>
fn from_str_binary(src: &str) -> Result<Self, ParseFixedError>
source§fn from_str_octal(src: &str) -> Result<Self, ParseFixedError>
fn from_str_octal(src: &str) -> Result<Self, ParseFixedError>
source§fn from_str_hex(src: &str) -> Result<Self, ParseFixedError>
fn from_str_hex(src: &str) -> Result<Self, ParseFixedError>
source§fn saturating_from_str(src: &str) -> Result<Self, ParseFixedError>
fn saturating_from_str(src: &str) -> Result<Self, ParseFixedError>
source§fn saturating_from_str_binary(src: &str) -> Result<Self, ParseFixedError>
fn saturating_from_str_binary(src: &str) -> Result<Self, ParseFixedError>
source§fn saturating_from_str_octal(src: &str) -> Result<Self, ParseFixedError>
fn saturating_from_str_octal(src: &str) -> Result<Self, ParseFixedError>
source§fn saturating_from_str_hex(src: &str) -> Result<Self, ParseFixedError>
fn saturating_from_str_hex(src: &str) -> Result<Self, ParseFixedError>
source§fn wrapping_from_str(src: &str) -> Result<Self, ParseFixedError>
fn wrapping_from_str(src: &str) -> Result<Self, ParseFixedError>
source§fn wrapping_from_str_binary(src: &str) -> Result<Self, ParseFixedError>
fn wrapping_from_str_binary(src: &str) -> Result<Self, ParseFixedError>
source§fn wrapping_from_str_octal(src: &str) -> Result<Self, ParseFixedError>
fn wrapping_from_str_octal(src: &str) -> Result<Self, ParseFixedError>
source§fn wrapping_from_str_hex(src: &str) -> Result<Self, ParseFixedError>
fn wrapping_from_str_hex(src: &str) -> Result<Self, ParseFixedError>
source§fn unwrapped_from_str(src: &str) -> Self
fn unwrapped_from_str(src: &str) -> Self
source§fn unwrapped_from_str_binary(src: &str) -> Self
fn unwrapped_from_str_binary(src: &str) -> Self
source§fn unwrapped_from_str_octal(src: &str) -> Self
fn unwrapped_from_str_octal(src: &str) -> Self
source§fn unwrapped_from_str_hex(src: &str) -> Self
fn unwrapped_from_str_hex(src: &str) -> Self
source§fn overflowing_from_str(src: &str) -> Result<(Self, bool), ParseFixedError>
fn overflowing_from_str(src: &str) -> Result<(Self, bool), ParseFixedError>
source§fn overflowing_from_str_binary(
src: &str,
) -> Result<(Self, bool), ParseFixedError>
fn overflowing_from_str_binary( src: &str, ) -> Result<(Self, bool), ParseFixedError>
source§fn overflowing_from_str_octal(
src: &str,
) -> Result<(Self, bool), ParseFixedError>
fn overflowing_from_str_octal( src: &str, ) -> Result<(Self, bool), ParseFixedError>
source§fn overflowing_from_str_hex(src: &str) -> Result<(Self, bool), ParseFixedError>
fn overflowing_from_str_hex(src: &str) -> Result<(Self, bool), ParseFixedError>
source§fn round_to_zero(self) -> Self
fn round_to_zero(self) -> Self
source§fn round(self) -> Self
fn round(self) -> Self
source§fn round_ties_even(self) -> Self
fn round_ties_even(self) -> Self
source§fn checked_ceil(self) -> Option<Self>
fn checked_ceil(self) -> Option<Self>
source§fn checked_floor(self) -> Option<Self>
fn checked_floor(self) -> Option<Self>
source§fn checked_round(self) -> Option<Self>
fn checked_round(self) -> Option<Self>
source§fn checked_round_ties_even(self) -> Option<Self>
fn checked_round_ties_even(self) -> Option<Self>
source§fn saturating_ceil(self) -> Self
fn saturating_ceil(self) -> Self
source§fn saturating_floor(self) -> Self
fn saturating_floor(self) -> Self
source§fn saturating_round(self) -> Self
fn saturating_round(self) -> Self
source§fn saturating_round_ties_even(self) -> Self
fn saturating_round_ties_even(self) -> Self
source§fn wrapping_ceil(self) -> Self
fn wrapping_ceil(self) -> Self
source§fn wrapping_floor(self) -> Self
fn wrapping_floor(self) -> Self
source§fn wrapping_round(self) -> Self
fn wrapping_round(self) -> Self
source§fn wrapping_round_ties_even(self) -> Self
fn wrapping_round_ties_even(self) -> Self
source§fn unwrapped_ceil(self) -> Self
fn unwrapped_ceil(self) -> Self
source§fn unwrapped_floor(self) -> Self
fn unwrapped_floor(self) -> Self
source§fn unwrapped_round(self) -> Self
fn unwrapped_round(self) -> Self
source§fn unwrapped_round_ties_even(self) -> Self
fn unwrapped_round_ties_even(self) -> Self
source§fn overflowing_ceil(self) -> (Self, bool)
fn overflowing_ceil(self) -> (Self, bool)
source§fn overflowing_floor(self) -> (Self, bool)
fn overflowing_floor(self) -> (Self, bool)
source§fn overflowing_round(self) -> (Self, bool)
fn overflowing_round(self) -> (Self, bool)
source§fn overflowing_round_ties_even(self) -> (Self, bool)
fn overflowing_round_ties_even(self) -> (Self, bool)
source§fn count_ones(self) -> u32
fn count_ones(self) -> u32
source§fn count_zeros(self) -> u32
fn count_zeros(self) -> u32
source§fn leading_ones(self) -> u32
fn leading_ones(self) -> u32
source§fn leading_zeros(self) -> u32
fn leading_zeros(self) -> u32
source§fn trailing_ones(self) -> u32
fn trailing_ones(self) -> u32
source§fn trailing_zeros(self) -> u32
fn trailing_zeros(self) -> u32
source§fn int_log(self, base: u32) -> i32
fn int_log(self, base: u32) -> i32
source§fn checked_int_log2(self) -> Option<i32>
fn checked_int_log2(self) -> Option<i32>
source§fn checked_int_log10(self) -> Option<i32>
fn checked_int_log10(self) -> Option<i32>
source§fn reverse_bits(self) -> Self
fn reverse_bits(self) -> Self
source§fn rotate_left(self, n: u32) -> Self
fn rotate_left(self, n: u32) -> Self
n
bits, wrapping the truncated bits to the right end. Read moresource§fn rotate_right(self, n: u32) -> Self
fn rotate_right(self, n: u32) -> Self
n
bits, wrapping the truncated bits to the left end. Read moresource§fn abs_diff(self, other: Self) -> Self::Unsigned
fn abs_diff(self, other: Self) -> Self::Unsigned
self
and other
using an unsigned type without any wrapping or panicking. Read moresource§fn next_multiple_of(self, other: Self) -> Self
fn next_multiple_of(self, other: Self) -> Self
other
. Read moresource§fn div_euclid(self, rhs: Self) -> Self
fn div_euclid(self, rhs: Self) -> Self
source§fn rem_euclid(self, rhs: Self) -> Self
fn rem_euclid(self, rhs: Self) -> Self
source§fn div_euclid_int(self, rhs: Self::Bits) -> Self
fn div_euclid_int(self, rhs: Self::Bits) -> Self
source§fn rem_euclid_int(self, rhs: Self::Bits) -> Self
fn rem_euclid_int(self, rhs: Self::Bits) -> Self
source§fn checked_neg(self) -> Option<Self>
fn checked_neg(self) -> Option<Self>
source§fn checked_add(self, rhs: Self) -> Option<Self>
fn checked_add(self, rhs: Self) -> Option<Self>
source§fn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
source§fn checked_mul(self, rhs: Self) -> Option<Self>
fn checked_mul(self, rhs: Self) -> Option<Self>
source§fn checked_div(self, rhs: Self) -> Option<Self>
fn checked_div(self, rhs: Self) -> Option<Self>
source§fn checked_rem(self, rhs: Self) -> Option<Self>
fn checked_rem(self, rhs: Self) -> Option<Self>
source§fn checked_recip(self) -> Option<Self>
fn checked_recip(self) -> Option<Self>
source§fn checked_next_multiple_of(self, other: Self) -> Option<Self>
fn checked_next_multiple_of(self, other: Self) -> Option<Self>
source§fn checked_mul_add(self, mul: Self, add: Self) -> Option<Self>
fn checked_mul_add(self, mul: Self, add: Self) -> Option<Self>
source§fn checked_add_prod(self, a: Self, b: Self) -> Option<Self>
fn checked_add_prod(self, a: Self, b: Self) -> Option<Self>
source§fn checked_mul_acc(&mut self, a: Self, b: Self) -> Option<()>
fn checked_mul_acc(&mut self, a: Self, b: Self) -> Option<()>
source§fn checked_div_euclid(self, rhs: Self) -> Option<Self>
fn checked_div_euclid(self, rhs: Self) -> Option<Self>
source§fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
fn checked_rem_euclid(self, rhs: Self) -> Option<Self>
source§fn checked_mul_int(self, rhs: Self::Bits) -> Option<Self>
fn checked_mul_int(self, rhs: Self::Bits) -> Option<Self>
source§fn checked_div_int(self, rhs: Self::Bits) -> Option<Self>
fn checked_div_int(self, rhs: Self::Bits) -> Option<Self>
source§fn checked_rem_int(self, rhs: Self::Bits) -> Option<Self>
fn checked_rem_int(self, rhs: Self::Bits) -> Option<Self>
source§fn checked_div_euclid_int(self, rhs: Self::Bits) -> Option<Self>
fn checked_div_euclid_int(self, rhs: Self::Bits) -> Option<Self>
source§fn checked_rem_euclid_int(self, rhs: Self::Bits) -> Option<Self>
fn checked_rem_euclid_int(self, rhs: Self::Bits) -> Option<Self>
source§fn checked_shl(self, rhs: u32) -> Option<Self>
fn checked_shl(self, rhs: u32) -> Option<Self>
source§fn checked_shr(self, rhs: u32) -> Option<Self>
fn checked_shr(self, rhs: u32) -> Option<Self>
source§fn checked_dist(self, other: Self) -> Option<Self>
fn checked_dist(self, other: Self) -> Option<Self>
source§fn checked_hypot(self, other: Self) -> Option<Self>
fn checked_hypot(self, other: Self) -> Option<Self>
source§fn checked_sqrt(self) -> Option<Self>
fn checked_sqrt(self) -> Option<Self>
source§fn checked_lerp(self, start: Self, end: Self) -> Option<Self>
fn checked_lerp(self, start: Self, end: Self) -> Option<Self>
source§fn checked_inv_lerp(self, start: Self, end: Self) -> Option<Self>
fn checked_inv_lerp(self, start: Self, end: Self) -> Option<Self>
source§fn saturating_neg(self) -> Self
fn saturating_neg(self) -> Self
source§fn saturating_add(self, rhs: Self) -> Self
fn saturating_add(self, rhs: Self) -> Self
source§fn saturating_sub(self, rhs: Self) -> Self
fn saturating_sub(self, rhs: Self) -> Self
source§fn saturating_mul(self, rhs: Self) -> Self
fn saturating_mul(self, rhs: Self) -> Self
source§fn saturating_div(self, rhs: Self) -> Self
fn saturating_div(self, rhs: Self) -> Self
source§fn saturating_recip(self) -> Self
fn saturating_recip(self) -> Self
source§fn saturating_next_multiple_of(self, other: Self) -> Self
fn saturating_next_multiple_of(self, other: Self) -> Self
other
. Read moresource§fn saturating_mul_add(self, mul: Self, add: Self) -> Self
fn saturating_mul_add(self, mul: Self, add: Self) -> Self
source§fn saturating_add_prod(self, a: Self, b: Self) -> Self
fn saturating_add_prod(self, a: Self, b: Self) -> Self
source§fn saturating_mul_acc(&mut self, a: Self, b: Self)
fn saturating_mul_acc(&mut self, a: Self, b: Self)
source§fn saturating_div_euclid(self, rhs: Self) -> Self
fn saturating_div_euclid(self, rhs: Self) -> Self
source§fn saturating_mul_int(self, rhs: Self::Bits) -> Self
fn saturating_mul_int(self, rhs: Self::Bits) -> Self
source§fn saturating_div_int(self, rhs: Self::Bits) -> Self
fn saturating_div_int(self, rhs: Self::Bits) -> Self
source§fn saturating_div_euclid_int(self, rhs: Self::Bits) -> Self
fn saturating_div_euclid_int(self, rhs: Self::Bits) -> Self
source§fn saturating_rem_euclid_int(self, rhs: Self::Bits) -> Self
fn saturating_rem_euclid_int(self, rhs: Self::Bits) -> Self
source§fn saturating_dist(self, other: Self) -> Self
fn saturating_dist(self, other: Self) -> Self
source§fn saturating_hypot(self, other: Self) -> Self
fn saturating_hypot(self, other: Self) -> Self
source§fn saturating_sqrt(self) -> Self
fn saturating_sqrt(self) -> Self
source§fn saturating_lerp(self, start: Self, end: Self) -> Self
fn saturating_lerp(self, start: Self, end: Self) -> Self
source§fn saturating_inv_lerp(self, start: Self, end: Self) -> Self
fn saturating_inv_lerp(self, start: Self, end: Self) -> Self
source§fn wrapping_neg(self) -> Self
fn wrapping_neg(self) -> Self
source§fn wrapping_add(self, rhs: Self) -> Self
fn wrapping_add(self, rhs: Self) -> Self
source§fn wrapping_sub(self, rhs: Self) -> Self
fn wrapping_sub(self, rhs: Self) -> Self
source§fn wrapping_mul(self, rhs: Self) -> Self
fn wrapping_mul(self, rhs: Self) -> Self
source§fn wrapping_div(self, rhs: Self) -> Self
fn wrapping_div(self, rhs: Self) -> Self
source§fn wrapping_recip(self) -> Self
fn wrapping_recip(self) -> Self
source§fn wrapping_next_multiple_of(self, other: Self) -> Self
fn wrapping_next_multiple_of(self, other: Self) -> Self
other
. Read moresource§fn wrapping_mul_add(self, mul: Self, add: Self) -> Self
fn wrapping_mul_add(self, mul: Self, add: Self) -> Self
source§fn wrapping_add_prod(self, a: Self, b: Self) -> Self
fn wrapping_add_prod(self, a: Self, b: Self) -> Self
source§fn wrapping_mul_acc(&mut self, a: Self, b: Self)
fn wrapping_mul_acc(&mut self, a: Self, b: Self)
source§fn wrapping_div_euclid(self, rhs: Self) -> Self
fn wrapping_div_euclid(self, rhs: Self) -> Self
source§fn wrapping_mul_int(self, rhs: Self::Bits) -> Self
fn wrapping_mul_int(self, rhs: Self::Bits) -> Self
source§fn wrapping_div_int(self, rhs: Self::Bits) -> Self
fn wrapping_div_int(self, rhs: Self::Bits) -> Self
source§fn wrapping_div_euclid_int(self, rhs: Self::Bits) -> Self
fn wrapping_div_euclid_int(self, rhs: Self::Bits) -> Self
source§fn wrapping_rem_euclid_int(self, rhs: Self::Bits) -> Self
fn wrapping_rem_euclid_int(self, rhs: Self::Bits) -> Self
source§fn wrapping_shl(self, rhs: u32) -> Self
fn wrapping_shl(self, rhs: u32) -> Self
rhs
if rhs
≥ the number of
bits, then shifts and returns the number. Read moresource§fn wrapping_shr(self, rhs: u32) -> Self
fn wrapping_shr(self, rhs: u32) -> Self
rhs
if rhs
≥ the number of
bits, then shifts and returns the number. Read moresource§fn wrapping_dist(self, other: Self) -> Self
fn wrapping_dist(self, other: Self) -> Self
source§fn wrapping_hypot(self, other: Self) -> Self
fn wrapping_hypot(self, other: Self) -> Self
source§fn wrapping_sqrt(self) -> Self
fn wrapping_sqrt(self) -> Self
source§fn wrapping_lerp(self, start: Self, end: Self) -> Self
fn wrapping_lerp(self, start: Self, end: Self) -> Self
source§fn wrapping_inv_lerp(self, start: Self, end: Self) -> Self
fn wrapping_inv_lerp(self, start: Self, end: Self) -> Self
source§fn unwrapped_neg(self) -> Self
fn unwrapped_neg(self) -> Self
source§fn unwrapped_add(self, rhs: Self) -> Self
fn unwrapped_add(self, rhs: Self) -> Self
source§fn unwrapped_sub(self, rhs: Self) -> Self
fn unwrapped_sub(self, rhs: Self) -> Self
source§fn unwrapped_mul(self, rhs: Self) -> Self
fn unwrapped_mul(self, rhs: Self) -> Self
source§fn unwrapped_div(self, rhs: Self) -> Self
fn unwrapped_div(self, rhs: Self) -> Self
source§fn unwrapped_rem(self, rhs: Self) -> Self
fn unwrapped_rem(self, rhs: Self) -> Self
source§fn unwrapped_recip(self) -> Self
fn unwrapped_recip(self) -> Self
source§fn unwrapped_next_multiple_of(self, other: Self) -> Self
fn unwrapped_next_multiple_of(self, other: Self) -> Self
other
. Returns the next multiple, panicking
on overflow. Read moresource§fn unwrapped_mul_add(self, mul: Self, add: Self) -> Self
fn unwrapped_mul_add(self, mul: Self, add: Self) -> Self
source§fn unwrapped_add_prod(self, a: Self, b: Self) -> Self
fn unwrapped_add_prod(self, a: Self, b: Self) -> Self
source§fn unwrapped_mul_acc(&mut self, a: Self, b: Self)
fn unwrapped_mul_acc(&mut self, a: Self, b: Self)
source§fn unwrapped_div_euclid(self, rhs: Self) -> Self
fn unwrapped_div_euclid(self, rhs: Self) -> Self
source§fn unwrapped_rem_euclid(self, rhs: Self) -> Self
fn unwrapped_rem_euclid(self, rhs: Self) -> Self
source§fn unwrapped_mul_int(self, rhs: Self::Bits) -> Self
fn unwrapped_mul_int(self, rhs: Self::Bits) -> Self
source§fn unwrapped_div_int(self, rhs: Self::Bits) -> Self
fn unwrapped_div_int(self, rhs: Self::Bits) -> Self
source§fn unwrapped_rem_int(self, rhs: Self::Bits) -> Self
fn unwrapped_rem_int(self, rhs: Self::Bits) -> Self
source§fn unwrapped_div_euclid_int(self, rhs: Self::Bits) -> Self
fn unwrapped_div_euclid_int(self, rhs: Self::Bits) -> Self
source§fn unwrapped_rem_euclid_int(self, rhs: Self::Bits) -> Self
fn unwrapped_rem_euclid_int(self, rhs: Self::Bits) -> Self
source§fn unwrapped_shl(self, rhs: u32) -> Self
fn unwrapped_shl(self, rhs: u32) -> Self
rhs
≥ the number of bits. Read moresource§fn unwrapped_shr(self, rhs: u32) -> Self
fn unwrapped_shr(self, rhs: u32) -> Self
rhs
≥ the number of bits. Read moresource§fn unwrapped_dist(self, other: Self) -> Self
fn unwrapped_dist(self, other: Self) -> Self
source§fn unwrapped_hypot(self, other: Self) -> Self
fn unwrapped_hypot(self, other: Self) -> Self
source§fn unwrapped_sqrt(self) -> Self
fn unwrapped_sqrt(self) -> Self
source§fn unwrapped_lerp(self, start: Self, end: Self) -> Self
fn unwrapped_lerp(self, start: Self, end: Self) -> Self
source§fn unwrapped_inv_lerp(self, start: Self, end: Self) -> Self
fn unwrapped_inv_lerp(self, start: Self, end: Self) -> Self
source§fn overflowing_neg(self) -> (Self, bool)
fn overflowing_neg(self) -> (Self, bool)
source§fn overflowing_add(self, rhs: Self) -> (Self, bool)
fn overflowing_add(self, rhs: Self) -> (Self, bool)
source§fn overflowing_sub(self, rhs: Self) -> (Self, bool)
fn overflowing_sub(self, rhs: Self) -> (Self, bool)
source§fn overflowing_mul(self, rhs: Self) -> (Self, bool)
fn overflowing_mul(self, rhs: Self) -> (Self, bool)
source§fn overflowing_div(self, rhs: Self) -> (Self, bool)
fn overflowing_div(self, rhs: Self) -> (Self, bool)
source§fn overflowing_recip(self) -> (Self, bool)
fn overflowing_recip(self) -> (Self, bool)
source§fn overflowing_next_multiple_of(self, other: Self) -> (Self, bool)
fn overflowing_next_multiple_of(self, other: Self) -> (Self, bool)
other
. Read moresource§fn overflowing_mul_add(self, mul: Self, add: Self) -> (Self, bool)
fn overflowing_mul_add(self, mul: Self, add: Self) -> (Self, bool)
source§fn overflowing_add_prod(self, a: Self, b: Self) -> (Self, bool)
fn overflowing_add_prod(self, a: Self, b: Self) -> (Self, bool)
source§fn overflowing_mul_acc(&mut self, a: Self, b: Self) -> bool
fn overflowing_mul_acc(&mut self, a: Self, b: Self) -> bool
source§fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool)
source§fn overflowing_mul_int(self, rhs: Self::Bits) -> (Self, bool)
fn overflowing_mul_int(self, rhs: Self::Bits) -> (Self, bool)
source§fn overflowing_div_int(self, rhs: Self::Bits) -> (Self, bool)
fn overflowing_div_int(self, rhs: Self::Bits) -> (Self, bool)
source§fn overflowing_div_euclid_int(self, rhs: Self::Bits) -> (Self, bool)
fn overflowing_div_euclid_int(self, rhs: Self::Bits) -> (Self, bool)
source§fn overflowing_rem_euclid_int(self, rhs: Self::Bits) -> (Self, bool)
fn overflowing_rem_euclid_int(self, rhs: Self::Bits) -> (Self, bool)
source§fn overflowing_dist(self, other: Self) -> (Self, bool)
fn overflowing_dist(self, other: Self) -> (Self, bool)
source§fn overflowing_hypot(self, other: Self) -> (Self, bool)
fn overflowing_hypot(self, other: Self) -> (Self, bool)
source§fn overflowing_sqrt(self) -> (Self, bool)
fn overflowing_sqrt(self) -> (Self, bool)
source§fn overflowing_lerp(self, start: Self, end: Self) -> (Self, bool)
fn overflowing_lerp(self, start: Self, end: Self) -> (Self, bool)
source§fn overflowing_inv_lerp(self, start: Self, end: Self) -> (Self, bool)
fn overflowing_inv_lerp(self, start: Self, end: Self) -> (Self, bool)
source§unsafe fn unchecked_add(self, rhs: Self) -> Self
unsafe fn unchecked_add(self, rhs: Self) -> Self
source§unsafe fn unchecked_sub(self, rhs: Self) -> Self
unsafe fn unchecked_sub(self, rhs: Self) -> Self
source§unsafe fn unchecked_mul_int(self, rhs: Self::Bits) -> Self
unsafe fn unchecked_mul_int(self, rhs: Self::Bits) -> Self
self
× rhs
, assuming overflow cannot occur. Read moresource§fn get_signed(&self) -> Option<&Self::Signed>
fn get_signed(&self) -> Option<&Self::Signed>
self
as FixedSigned
if the type is signed,
or None
if it is unsigned. Read moresource§fn get_unsigned(&self) -> Option<&Self::Unsigned>
fn get_unsigned(&self) -> Option<&Self::Unsigned>
self
as FixedUnsigned
if the type is
unsigned, or None
if it is signed. Read moresource§fn get_signed_mut(&mut self) -> Option<&mut Self::Signed>
fn get_signed_mut(&mut self) -> Option<&mut Self::Signed>
self
as FixedSigned
if the type is
signed, or None
if it is unsigned. Read moresource§fn get_unsigned_mut(&mut self) -> Option<&mut Self::Unsigned>
fn get_unsigned_mut(&mut self) -> Option<&mut Self::Unsigned>
self
as FixedUnsigned
if the type
is unsigned, or None
if it is signed. Read moresource§fn round_ties_to_even(self) -> Self
fn round_ties_to_even(self) -> Self
round_ties_even
source§fn checked_round_ties_to_even(self) -> Option<Self>
fn checked_round_ties_to_even(self) -> Option<Self>
checked_round_ties_even
None
on overflow.source§fn saturating_round_ties_to_even(self) -> Self
fn saturating_round_ties_to_even(self) -> Self
saturating_round_ties_even
source§fn wrapping_round_ties_to_even(self) -> Self
fn wrapping_round_ties_to_even(self) -> Self
wrapping_round_ties_even
source§fn unwrapped_round_ties_to_even(self) -> Self
fn unwrapped_round_ties_to_even(self) -> Self
unwrapped_round_ties_even
source§fn overflowing_round_ties_to_even(self) -> (Self, bool)
fn overflowing_round_ties_to_even(self) -> (Self, bool)
overflowing_round_ties_even
source§impl<Frac: LeEqU32> FixedUnsigned for FixedU32<Frac>
impl<Frac: LeEqU32> FixedUnsigned for FixedU32<Frac>
source§fn significant_bits(self) -> u32
fn significant_bits(self) -> u32
source§fn is_power_of_two(self) -> bool
fn is_power_of_two(self) -> bool
source§fn highest_one(self) -> Self
fn highest_one(self) -> Self
self
is zero. Read moresource§fn next_power_of_two(self) -> Self
fn next_power_of_two(self) -> Self
self
. Read moresource§fn add_signed(self, rhs: Self::Signed) -> Self
fn add_signed(self, rhs: Self::Signed) -> Self
source§fn sub_signed(self, rhs: Self::Signed) -> Self
fn sub_signed(self, rhs: Self::Signed) -> Self
source§fn checked_next_power_of_two(self) -> Option<Self>
fn checked_next_power_of_two(self) -> Option<Self>
source§fn checked_add_signed(self, rhs: Self::Signed) -> Option<Self>
fn checked_add_signed(self, rhs: Self::Signed) -> Option<Self>
source§fn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self>
fn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self>
source§fn saturating_add_signed(self, rhs: Self::Signed) -> Self
fn saturating_add_signed(self, rhs: Self::Signed) -> Self
source§fn saturating_sub_signed(self, rhs: Self::Signed) -> Self
fn saturating_sub_signed(self, rhs: Self::Signed) -> Self
source§fn wrapping_next_power_of_two(self) -> Self
fn wrapping_next_power_of_two(self) -> Self
self
, wrapping
to 0 if the next power of two is too large to represent. Read moresource§fn wrapping_add_signed(self, rhs: Self::Signed) -> Self
fn wrapping_add_signed(self, rhs: Self::Signed) -> Self
source§fn wrapping_sub_signed(self, rhs: Self::Signed) -> Self
fn wrapping_sub_signed(self, rhs: Self::Signed) -> Self
source§fn unwrapped_next_power_of_two(self) -> Self
fn unwrapped_next_power_of_two(self) -> Self
self
, panicking
if the next power of two is too large to represent. Read moresource§fn unwrapped_add_signed(self, rhs: Self::Signed) -> Self
fn unwrapped_add_signed(self, rhs: Self::Signed) -> Self
source§fn unwrapped_sub_signed(self, rhs: Self::Signed) -> Self
fn unwrapped_sub_signed(self, rhs: Self::Signed) -> Self
source§impl<Frac: LeEqU32> FloatConst for FixedU32<Frac>
impl<Frac: LeEqU32> FloatConst for FixedU32<Frac>
source§fn FRAC_1_SQRT_2() -> Self
fn FRAC_1_SQRT_2() -> Self
1.0 / sqrt(2.0)
.source§fn FRAC_2_SQRT_PI() -> Self
fn FRAC_2_SQRT_PI() -> Self
2.0 / sqrt(π)
.source§impl<Frac: LeEqU32> FromBytes for FixedU32<Frac>
impl<Frac: LeEqU32> FromBytes for FixedU32<Frac>
type Bytes = <FixedU32<Frac> as Fixed>::Bytes
source§fn from_be_bytes(bytes: &Self::Bytes) -> Self
fn from_be_bytes(bytes: &Self::Bytes) -> Self
source§fn from_le_bytes(bytes: &Self::Bytes) -> Self
fn from_le_bytes(bytes: &Self::Bytes) -> Self
source§fn from_ne_bytes(bytes: &Self::Bytes) -> Self
fn from_ne_bytes(bytes: &Self::Bytes) -> Self
source§impl<Frac: LeEqU32> FromFixed for FixedU32<Frac>
impl<Frac: LeEqU32> FromFixed for FixedU32<Frac>
source§fn from_fixed<F: Fixed>(src: F) -> Self
fn from_fixed<F: Fixed>(src: F) -> Self
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.
source§fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>
fn checked_from_fixed<F: Fixed>(src: F) -> Option<Self>
Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn saturating_from_fixed<F: Fixed>(src: F) -> Self
fn saturating_from_fixed<F: Fixed>(src: F) -> Self
Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn wrapping_from_fixed<F: Fixed>(src: F) -> Self
fn wrapping_from_fixed<F: Fixed>(src: F) -> Self
Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)
fn overflowing_from_fixed<F: Fixed>(src: F) -> (Self, bool)
source§fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self
fn unwrapped_from_fixed<F: Fixed>(src: F) -> Self
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.
source§impl<Frac: LeEqU32> FromPrimitive for FixedU32<Frac>
impl<Frac: LeEqU32> FromPrimitive for FixedU32<Frac>
source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned.source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128
to return an optional value of this type. If the
value cannot be represented by this type, then None
is returned. Read moresource§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI128<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI128<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedI128<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedI128<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI16<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI16<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedI16<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedI16<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI32<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI32<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedI32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedI32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI64<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI64<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedI64<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedI64<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI8<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedI8<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedI8<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedI8<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU128<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU128<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedU128<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU128<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU16<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU16<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedU16<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU16<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU128> LosslessTryFrom<FixedU32<FracSrc>> for FixedI128<FracDst>
impl<FracSrc, FracDst: LeEqU128> LosslessTryFrom<FixedU32<FracSrc>> for FixedI128<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU16> LosslessTryFrom<FixedU32<FracSrc>> for FixedI16<FracDst>
impl<FracSrc, FracDst: LeEqU16> LosslessTryFrom<FixedU32<FracSrc>> for FixedI16<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU32<FracSrc>> for FixedI32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU32<FracSrc>> for FixedI32<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU64> LosslessTryFrom<FixedU32<FracSrc>> for FixedI64<FracDst>
impl<FracSrc, FracDst: LeEqU64> LosslessTryFrom<FixedU32<FracSrc>> for FixedI64<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU8> LosslessTryFrom<FixedU32<FracSrc>> for FixedI8<FracDst>
impl<FracSrc, FracDst: LeEqU8> LosslessTryFrom<FixedU32<FracSrc>> for FixedI8<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU128> LosslessTryFrom<FixedU32<FracSrc>> for FixedU128<FracDst>
impl<FracSrc, FracDst: LeEqU128> LosslessTryFrom<FixedU32<FracSrc>> for FixedU128<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU16> LosslessTryFrom<FixedU32<FracSrc>> for FixedU16<FracDst>
impl<FracSrc, FracDst: LeEqU16> LosslessTryFrom<FixedU32<FracSrc>> for FixedU16<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU32<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU32<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU64> LosslessTryFrom<FixedU32<FracSrc>> for FixedU64<FracDst>
impl<FracSrc, FracDst: LeEqU64> LosslessTryFrom<FixedU32<FracSrc>> for FixedU64<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU8> LosslessTryFrom<FixedU32<FracSrc>> for FixedU8<FracDst>
impl<FracSrc, FracDst: LeEqU8> LosslessTryFrom<FixedU32<FracSrc>> for FixedU8<FracDst>
source§fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU32<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU64<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU64<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedU64<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU64<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU8<FracSrc>> for FixedU32<FracDst>
impl<FracSrc, FracDst: LeEqU32> LosslessTryFrom<FixedU8<FracSrc>> for FixedU32<FracDst>
source§fn lossless_try_from(src: FixedU8<FracSrc>) -> Option<Self>
fn lossless_try_from(src: FixedU8<FracSrc>) -> Option<Self>
Converts a fixed-pint number.
This conversion may fail (fallible) but does not lose precision (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<bool> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<bool> for FixedU32<Frac>
source§fn lossless_try_from(src: bool) -> Option<Self>
fn lossless_try_from(src: bool) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<i128> for FixedU32<Frac>
source§fn lossless_try_from(src: i128) -> Option<Self>
fn lossless_try_from(src: i128) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<i16> for FixedU32<Frac>
source§fn lossless_try_from(src: i16) -> Option<Self>
fn lossless_try_from(src: i16) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<i32> for FixedU32<Frac>
source§fn lossless_try_from(src: i32) -> Option<Self>
fn lossless_try_from(src: i32) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<i64> for FixedU32<Frac>
source§fn lossless_try_from(src: i64) -> Option<Self>
fn lossless_try_from(src: i64) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<i8> for FixedU32<Frac>
source§fn lossless_try_from(src: i8) -> Option<Self>
fn lossless_try_from(src: i8) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<isize> for FixedU32<Frac>
source§fn lossless_try_from(src: isize) -> Option<Self>
fn lossless_try_from(src: isize) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<u128> for FixedU32<Frac>
source§fn lossless_try_from(src: u128) -> Option<Self>
fn lossless_try_from(src: u128) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<u16> for FixedU32<Frac>
source§fn lossless_try_from(src: u16) -> Option<Self>
fn lossless_try_from(src: u16) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<u32> for FixedU32<Frac>
source§fn lossless_try_from(src: u32) -> Option<Self>
fn lossless_try_from(src: u32) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<u64> for FixedU32<Frac>
source§fn lossless_try_from(src: u64) -> Option<Self>
fn lossless_try_from(src: u64) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<u8> for FixedU32<Frac>
source§fn lossless_try_from(src: u8) -> Option<Self>
fn lossless_try_from(src: u8) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<Frac: LeEqU32> LosslessTryFrom<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> LosslessTryFrom<usize> for FixedU32<Frac>
source§fn lossless_try_from(src: usize) -> Option<Self>
fn lossless_try_from(src: usize) -> Option<Self>
Converts an integer to a fixed-point number.
This conversion may fail (fallible) but cannot lose any fractional bits (lossless).
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> LossyFrom<FixedU128<FracSrc>> for FixedU32<FracDst>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> LossyFrom<FixedU128<FracSrc>> for FixedU32<FracDst>
source§fn lossy_from(src: FixedU128<FracSrc>) -> Self
fn lossy_from(src: FixedU128<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> LossyFrom<FixedU16<FracSrc>> for FixedU32<FracDst>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> LossyFrom<FixedU16<FracSrc>> for FixedU32<FracDst>
source§fn lossy_from(src: FixedU16<FracSrc>) -> Self
fn lossy_from(src: FixedU16<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for F128
source§fn lossy_from(src: FixedU32<Frac>) -> F128
fn lossy_from(src: FixedU32<Frac>) -> F128
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for F128Bits
source§fn lossy_from(src: FixedU32<Frac>) -> F128Bits
fn lossy_from(src: FixedU32<Frac>) -> F128Bits
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for half_bf16
source§fn lossy_from(src: FixedU32<Frac>) -> half_bf16
fn lossy_from(src: FixedU32<Frac>) -> half_bf16
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for half_f16
source§fn lossy_from(src: FixedU32<Frac>) -> half_f16
fn lossy_from(src: FixedU32<Frac>) -> half_f16
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for f32
source§fn lossy_from(src: FixedU32<Frac>) -> f32
fn lossy_from(src: FixedU32<Frac>) -> f32
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> LossyFrom<FixedU32<Frac>> for f64
source§fn lossy_from(src: FixedU32<Frac>) -> f64
fn lossy_from(src: FixedU32<Frac>) -> f64
Converts a fixed-point number to a floating-point number.
This conversion never fails (infallible) but may lose precision (lossy). Rounding is to the nearest, with ties rounded to even.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> LossyFrom<FixedU32<FracSrc>> for FixedI128<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> LossyFrom<FixedU32<FracSrc>> for FixedI128<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> LossyFrom<FixedU32<FracSrc>> for FixedI16<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> LossyFrom<FixedU32<FracSrc>> for FixedI16<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> LossyFrom<FixedU32<FracSrc>> for FixedI32<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> LossyFrom<FixedU32<FracSrc>> for FixedI32<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> LossyFrom<FixedU32<FracSrc>> for FixedI64<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> LossyFrom<FixedU32<FracSrc>> for FixedI64<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> LossyFrom<FixedU32<FracSrc>> for FixedI8<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> LossyFrom<FixedU32<FracSrc>> for FixedI8<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> LossyFrom<FixedU32<FracSrc>> for FixedU128<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> LossyFrom<FixedU32<FracSrc>> for FixedU128<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> LossyFrom<FixedU32<FracSrc>> for FixedU16<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> LossyFrom<FixedU32<FracSrc>> for FixedU16<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> LossyFrom<FixedU32<FracSrc>> for FixedU32<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> LossyFrom<FixedU32<FracSrc>> for FixedU32<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> LossyFrom<FixedU32<FracSrc>> for FixedU64<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> LossyFrom<FixedU32<FracSrc>> for FixedU64<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> LossyFrom<FixedU32<FracSrc>> for FixedU8<FracDst>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> LossyFrom<FixedU32<FracSrc>> for FixedU8<FracDst>
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i128
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i128
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i16
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i16
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i32
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i32
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i64
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i64
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i8
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for i8
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for isize
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for isize
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u128
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u128
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u16
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u16
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u32
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u32
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u64
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u64
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u8
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for u8
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for usize
impl<FracSrc: LeEqU32> LossyFrom<FixedU32<FracSrc>> for usize
source§fn lossy_from(src: FixedU32<FracSrc>) -> Self
fn lossy_from(src: FixedU32<FracSrc>) -> Self
Converts a fixed-point number to an integer.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> LossyFrom<FixedU64<FracSrc>> for FixedU32<FracDst>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> LossyFrom<FixedU64<FracSrc>> for FixedU32<FracDst>
source§fn lossy_from(src: FixedU64<FracSrc>) -> Self
fn lossy_from(src: FixedU64<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> LossyFrom<FixedU8<FracSrc>> for FixedU32<FracDst>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> LossyFrom<FixedU8<FracSrc>> for FixedU32<FracDst>
source§fn lossy_from(src: FixedU8<FracSrc>) -> Self
fn lossy_from(src: FixedU8<FracSrc>) -> Self
Converts a fixed-pint number.
This conversion never fails (infallible) but may lose precision (lossy). Any fractional bits in the source that cannot be represented in the destination are discarded, which rounds towards −∞.
source§impl<FracDst: LeEqU32> LossyFrom<bool> for FixedU32<FracDst>
impl<FracDst: LeEqU32> LossyFrom<bool> for FixedU32<FracDst>
source§fn lossy_from(src: bool) -> Self
fn lossy_from(src: bool) -> Self
Converts a bool
to a fixed-point number.
This conversion never fails (infallible) and cannot lose any fractional bits, so it is actually lossless.
source§impl<FracDst: LeEqU32> LossyFrom<u16> for FixedU32<FracDst>
impl<FracDst: LeEqU32> LossyFrom<u16> for FixedU32<FracDst>
source§fn lossy_from(src: u16) -> Self
fn lossy_from(src: u16) -> Self
Converts an integer to a fixed-point number.
This conversion never fails (infallible) and cannot lose any fractional bits, so it is actually lossless.
source§impl LossyFrom<u32> for FixedU32<U0>
impl LossyFrom<u32> for FixedU32<U0>
source§fn lossy_from(src: u32) -> Self
fn lossy_from(src: u32) -> Self
Converts an integer to a fixed-point number.
This conversion never fails (infallible) and actually does not lose any precision (lossless).
source§impl<FracDst: LeEqU32> LossyFrom<u8> for FixedU32<FracDst>
impl<FracDst: LeEqU32> LossyFrom<u8> for FixedU32<FracDst>
source§fn lossy_from(src: u8) -> Self
fn lossy_from(src: u8) -> Self
Converts an integer to a fixed-point number.
This conversion never fails (infallible) and cannot lose any fractional bits, so it is actually lossless.
source§impl<Frac, MulFrac: LeEqU32> MulAddAssign<FixedU32<MulFrac>> for FixedU32<Frac>
impl<Frac, MulFrac: LeEqU32> MulAddAssign<FixedU32<MulFrac>> for FixedU32<Frac>
source§fn mul_add_assign(&mut self, a: FixedU32<MulFrac>, b: FixedU32<Frac>)
fn mul_add_assign(&mut self, a: FixedU32<MulFrac>, b: FixedU32<Frac>)
*self = (*self * a) + b
source§impl<Frac, RhsFrac: LeEqU32> MulAssign<&FixedU32<RhsFrac>> for FixedU32<Frac>
impl<Frac, RhsFrac: LeEqU32> MulAssign<&FixedU32<RhsFrac>> for FixedU32<Frac>
source§fn mul_assign(&mut self, rhs: &FixedU32<RhsFrac>)
fn mul_assign(&mut self, rhs: &FixedU32<RhsFrac>)
*=
operation. Read moresource§impl<Frac: LeEqU32> MulAssign<&u32> for FixedU32<Frac>
impl<Frac: LeEqU32> MulAssign<&u32> for FixedU32<Frac>
source§fn mul_assign(&mut self, rhs: &u32)
fn mul_assign(&mut self, rhs: &u32)
*=
operation. Read moresource§impl<Frac, RhsFrac: LeEqU32> MulAssign<FixedU32<RhsFrac>> for FixedU32<Frac>
impl<Frac, RhsFrac: LeEqU32> MulAssign<FixedU32<RhsFrac>> for FixedU32<Frac>
source§fn mul_assign(&mut self, rhs: FixedU32<RhsFrac>)
fn mul_assign(&mut self, rhs: FixedU32<RhsFrac>)
*=
operation. Read moresource§impl<Frac: LeEqU32> MulAssign<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> MulAssign<u32> for FixedU32<Frac>
source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*=
operation. Read moresource§impl<Frac> Num for FixedU32<Frac>
impl<Frac> Num for FixedU32<Frac>
type FromStrRadixErr = RadixParseFixedError
source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl<Frac: Unsigned> Ord for FixedU32<Frac>
impl<Frac: Unsigned> Ord for FixedU32<Frac>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<Frac> OverflowingAdd for FixedU32<Frac>
impl<Frac> OverflowingAdd for FixedU32<Frac>
source§fn overflowing_add(&self, v: &Self) -> (Self, bool)
fn overflowing_add(&self, v: &Self) -> (Self, bool)
source§impl<Frac: LeEqU32> OverflowingCast<F128> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<F128> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (F128, bool)
fn overflowing_cast(self) -> (F128, bool)
source§impl<Frac: LeEqU32> OverflowingCast<F128Bits> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<F128Bits> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (F128Bits, bool)
fn overflowing_cast(self) -> (F128Bits, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> OverflowingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> OverflowingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedI128<FracDst>, bool)
fn overflowing_cast(self) -> (FixedI128<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> OverflowingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> OverflowingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedI16<FracDst>, bool)
fn overflowing_cast(self) -> (FixedI16<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedI32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedI32<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> OverflowingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> OverflowingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedI64<FracDst>, bool)
fn overflowing_cast(self) -> (FixedI64<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> OverflowingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> OverflowingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedI8<FracDst>, bool)
fn overflowing_cast(self) -> (FixedI8<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> OverflowingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> OverflowingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU128<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU128<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> OverflowingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> OverflowingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU16<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU16<FracDst>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for F128
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for F128Bits
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for half_bf16
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for bool
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for bool
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for half_f16
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for f32
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for f64
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i128
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i128
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i16
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i16
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i32
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i32
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i64
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i64
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i8
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for i8
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for isize
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for isize
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u128
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u128
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u16
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u16
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u32
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u32
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u64
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u64
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u8
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for u8
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for usize
impl<Frac: LeEqU32> OverflowingCast<FixedU32<Frac>> for usize
source§fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
fn overflowing_cast(self) -> (FixedU32<Frac>, bool)
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> OverflowingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
source§fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU32<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> OverflowingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> OverflowingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU64<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU64<FracDst>, bool)
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> OverflowingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> OverflowingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
source§fn overflowing_cast(self) -> (FixedU8<FracDst>, bool)
fn overflowing_cast(self) -> (FixedU8<FracDst>, bool)
source§impl<Frac: LeEqU32> OverflowingCast<bf16> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<bf16> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (half_bf16, bool)
fn overflowing_cast(self) -> (half_bf16, bool)
source§impl<Frac: LeEqU32> OverflowingCast<f16> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<f16> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (half_f16, bool)
fn overflowing_cast(self) -> (half_f16, bool)
source§impl<Frac: LeEqU32> OverflowingCast<f32> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<f32> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (f32, bool)
fn overflowing_cast(self) -> (f32, bool)
source§impl<Frac: LeEqU32> OverflowingCast<f64> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<f64> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (f64, bool)
fn overflowing_cast(self) -> (f64, bool)
source§impl<Frac: LeEqU32> OverflowingCast<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<i128> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (i128, bool)
fn overflowing_cast(self) -> (i128, bool)
source§impl<Frac: LeEqU32> OverflowingCast<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<i16> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (i16, bool)
fn overflowing_cast(self) -> (i16, bool)
source§impl<Frac: LeEqU32> OverflowingCast<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<i32> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (i32, bool)
fn overflowing_cast(self) -> (i32, bool)
source§impl<Frac: LeEqU32> OverflowingCast<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<i64> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (i64, bool)
fn overflowing_cast(self) -> (i64, bool)
source§impl<Frac: LeEqU32> OverflowingCast<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<i8> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (i8, bool)
fn overflowing_cast(self) -> (i8, bool)
source§impl<Frac: LeEqU32> OverflowingCast<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<isize> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (isize, bool)
fn overflowing_cast(self) -> (isize, bool)
source§impl<Frac: LeEqU32> OverflowingCast<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<u128> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (u128, bool)
fn overflowing_cast(self) -> (u128, bool)
source§impl<Frac: LeEqU32> OverflowingCast<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<u16> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (u16, bool)
fn overflowing_cast(self) -> (u16, bool)
source§impl<Frac: LeEqU32> OverflowingCast<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<u32> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (u32, bool)
fn overflowing_cast(self) -> (u32, bool)
source§impl<Frac: LeEqU32> OverflowingCast<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<u64> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (u64, bool)
fn overflowing_cast(self) -> (u64, bool)
source§impl<Frac: LeEqU32> OverflowingCast<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<u8> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (u8, bool)
fn overflowing_cast(self) -> (u8, bool)
source§impl<Frac: LeEqU32> OverflowingCast<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingCast<usize> for FixedU32<Frac>
source§fn overflowing_cast(self) -> (usize, bool)
fn overflowing_cast(self) -> (usize, bool)
source§impl<Frac: LeEqU32> OverflowingMul for FixedU32<Frac>
impl<Frac: LeEqU32> OverflowingMul for FixedU32<Frac>
source§fn overflowing_mul(&self, v: &Self) -> (Self, bool)
fn overflowing_mul(&self, v: &Self) -> (Self, bool)
source§impl<Frac> OverflowingSub for FixedU32<Frac>
impl<Frac> OverflowingSub for FixedU32<Frac>
source§fn overflowing_sub(&self, v: &Self) -> (Self, bool)
fn overflowing_sub(&self, v: &Self) -> (Self, bool)
source§impl<Frac: Unsigned> PartialEq<F128Bits> for FixedU32<Frac>
impl<Frac: Unsigned> PartialEq<F128Bits> for FixedU32<Frac>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI128<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI128<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI16<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI16<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI32<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI32<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI64<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI64<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI8<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedI8<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU128<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU128<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU16<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU16<FracRhs>> for FixedU32<FracLhs>
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for F128
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for F128
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for F128Bits
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for F128Bits
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for half_bf16
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for half_bf16
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for half_f16
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for half_f16
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for f32
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for f32
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for f64
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for f64
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i128
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i128
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i16
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i16
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i32
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i32
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i64
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i64
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i8
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for i8
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for isize
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for isize
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u128
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u128
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u16
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u16
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u32
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u32
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u64
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u64
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u8
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for u8
source§impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for usize
impl<Frac: Unsigned> PartialEq<FixedU32<Frac>> for usize
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI128<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI128<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI16<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI16<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI64<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI64<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI8<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedI8<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU128<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU128<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU16<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU16<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU64<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU64<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU8<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU32<FracRhs>> for FixedU8<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU64<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU64<FracRhs>> for FixedU32<FracLhs>
source§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU8<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialEq<FixedU8<FracRhs>> for FixedU32<FracLhs>
source§impl<Frac: Unsigned> PartialEq<bf16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialEq<bf16> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialEq<f16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialEq<f16> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<F128> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<F128> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<F128Bits> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<F128Bits> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI128<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI128<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedI128<FracRhs>) -> bool
fn le(&self, rhs: &FixedI128<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI16<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI16<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedI16<FracRhs>) -> bool
fn le(&self, rhs: &FixedI16<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI32<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI32<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedI32<FracRhs>) -> bool
fn le(&self, rhs: &FixedI32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI64<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI64<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedI64<FracRhs>) -> bool
fn le(&self, rhs: &FixedI64<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI8<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedI8<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedI8<FracRhs>) -> bool
fn le(&self, rhs: &FixedI8<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU128<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU128<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedU128<FracRhs>) -> bool
fn le(&self, rhs: &FixedU128<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU16<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU16<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedU16<FracRhs>) -> bool
fn le(&self, rhs: &FixedU16<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for F128
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for F128
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for F128Bits
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for F128Bits
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for half_bf16
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for half_bf16
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for half_f16
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for half_f16
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for f32
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for f32
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for f64
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for f64
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i128
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i128
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i16
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i16
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i32
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i32
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i64
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i64
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i8
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for i8
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for isize
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for isize
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u128
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u128
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u16
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u16
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u32
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u32
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u64
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u64
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u8
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for u8
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for usize
impl<Frac: Unsigned> PartialOrd<FixedU32<Frac>> for usize
source§fn le(&self, rhs: &FixedU32<Frac>) -> bool
fn le(&self, rhs: &FixedU32<Frac>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI128<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI128<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI16<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI16<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI32<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI64<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI64<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI8<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedI8<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU128<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU128<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU16<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU16<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU64<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU64<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU8<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU32<FracRhs>> for FixedU8<FracLhs>
source§fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
fn le(&self, rhs: &FixedU32<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU64<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU64<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedU64<FracRhs>) -> bool
fn le(&self, rhs: &FixedU64<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU8<FracRhs>> for FixedU32<FracLhs>
impl<FracLhs: Unsigned, FracRhs: Unsigned> PartialOrd<FixedU8<FracRhs>> for FixedU32<FracLhs>
source§fn le(&self, rhs: &FixedU8<FracRhs>) -> bool
fn le(&self, rhs: &FixedU8<FracRhs>) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<bf16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<bf16> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<f16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<f16> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<f32> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<f32> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<f64> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<f64> for FixedU32<Frac>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<Frac: Unsigned> PartialOrd<i128> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<i128> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<i16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<i16> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<i32> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<i32> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<i64> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<i64> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<i8> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<i8> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<isize> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<isize> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<u128> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<u128> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<u16> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<u16> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<u32> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<u32> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<u64> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<u64> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<u8> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<u8> for FixedU32<Frac>
source§impl<Frac: Unsigned> PartialOrd<usize> for FixedU32<Frac>
impl<Frac: Unsigned> PartialOrd<usize> for FixedU32<Frac>
source§impl<Frac> RemAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> RemAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: &FixedU32<Frac>)
fn rem_assign(&mut self, rhs: &FixedU32<Frac>)
%=
operation. Read moresource§impl<Frac: LeEqU32> RemAssign<&NonZero<u32>> for FixedU32<Frac>
impl<Frac: LeEqU32> RemAssign<&NonZero<u32>> for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: &NonZeroU32)
fn rem_assign(&mut self, rhs: &NonZeroU32)
%=
operation. Read moresource§impl<Frac: LeEqU32> RemAssign<&u32> for FixedU32<Frac>
impl<Frac: LeEqU32> RemAssign<&u32> for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: &u32)
fn rem_assign(&mut self, rhs: &u32)
%=
operation. Read moresource§impl<Frac: LeEqU32> RemAssign<NonZero<u32>> for FixedU32<Frac>
impl<Frac: LeEqU32> RemAssign<NonZero<u32>> for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: NonZeroU32)
fn rem_assign(&mut self, rhs: NonZeroU32)
%=
operation. Read moresource§impl<Frac: LeEqU32> RemAssign<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> RemAssign<u32> for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: u32)
fn rem_assign(&mut self, rhs: u32)
%=
operation. Read moresource§impl<Frac> RemAssign for FixedU32<Frac>
impl<Frac> RemAssign for FixedU32<Frac>
source§fn rem_assign(&mut self, rhs: FixedU32<Frac>)
fn rem_assign(&mut self, rhs: FixedU32<Frac>)
%=
operation. Read moresource§impl<Frac> SaturatingAdd for FixedU32<Frac>
impl<Frac> SaturatingAdd for FixedU32<Frac>
source§fn saturating_add(&self, v: &Self) -> Self
fn saturating_add(&self, v: &Self) -> Self
self + other
, saturating at the relevant high or low boundary of
the type.source§impl<Frac: LeEqU32> SaturatingCast<F128> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<F128> for FixedU32<Frac>
source§fn saturating_cast(self) -> F128
fn saturating_cast(self) -> F128
source§impl<Frac: LeEqU32> SaturatingCast<F128Bits> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<F128Bits> for FixedU32<Frac>
source§fn saturating_cast(self) -> F128Bits
fn saturating_cast(self) -> F128Bits
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> SaturatingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> SaturatingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedI128<FracDst>
fn saturating_cast(self) -> FixedI128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> SaturatingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> SaturatingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedI16<FracDst>
fn saturating_cast(self) -> FixedI16<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedI32<FracDst>
fn saturating_cast(self) -> FixedI32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> SaturatingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> SaturatingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedI64<FracDst>
fn saturating_cast(self) -> FixedI64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> SaturatingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> SaturatingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedI8<FracDst>
fn saturating_cast(self) -> FixedI8<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> SaturatingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> SaturatingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedU128<FracDst>
fn saturating_cast(self) -> FixedU128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> SaturatingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> SaturatingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedU16<FracDst>
fn saturating_cast(self) -> FixedU16<FracDst>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for F128
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for F128Bits
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for half_bf16
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for bool
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for bool
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for half_f16
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for f32
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for f64
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i128
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i128
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i16
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i16
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i32
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i32
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i64
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i64
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i8
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for i8
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for isize
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for isize
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u128
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u128
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u16
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u16
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u32
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u32
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u64
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u64
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u8
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for u8
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for usize
impl<Frac: LeEqU32> SaturatingCast<FixedU32<Frac>> for usize
source§fn saturating_cast(self) -> FixedU32<Frac>
fn saturating_cast(self) -> FixedU32<Frac>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> SaturatingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
source§fn saturating_cast(self) -> FixedU32<FracDst>
fn saturating_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> SaturatingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> SaturatingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedU64<FracDst>
fn saturating_cast(self) -> FixedU64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> SaturatingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> SaturatingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
source§fn saturating_cast(self) -> FixedU8<FracDst>
fn saturating_cast(self) -> FixedU8<FracDst>
source§impl<Frac: LeEqU32> SaturatingCast<bf16> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<bf16> for FixedU32<Frac>
source§fn saturating_cast(self) -> half_bf16
fn saturating_cast(self) -> half_bf16
source§impl<Frac: LeEqU32> SaturatingCast<f16> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<f16> for FixedU32<Frac>
source§fn saturating_cast(self) -> half_f16
fn saturating_cast(self) -> half_f16
source§impl<Frac: LeEqU32> SaturatingCast<f32> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<f32> for FixedU32<Frac>
source§fn saturating_cast(self) -> f32
fn saturating_cast(self) -> f32
source§impl<Frac: LeEqU32> SaturatingCast<f64> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<f64> for FixedU32<Frac>
source§fn saturating_cast(self) -> f64
fn saturating_cast(self) -> f64
source§impl<Frac: LeEqU32> SaturatingCast<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<i128> for FixedU32<Frac>
source§fn saturating_cast(self) -> i128
fn saturating_cast(self) -> i128
source§impl<Frac: LeEqU32> SaturatingCast<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<i16> for FixedU32<Frac>
source§fn saturating_cast(self) -> i16
fn saturating_cast(self) -> i16
source§impl<Frac: LeEqU32> SaturatingCast<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<i32> for FixedU32<Frac>
source§fn saturating_cast(self) -> i32
fn saturating_cast(self) -> i32
source§impl<Frac: LeEqU32> SaturatingCast<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<i64> for FixedU32<Frac>
source§fn saturating_cast(self) -> i64
fn saturating_cast(self) -> i64
source§impl<Frac: LeEqU32> SaturatingCast<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<i8> for FixedU32<Frac>
source§fn saturating_cast(self) -> i8
fn saturating_cast(self) -> i8
source§impl<Frac: LeEqU32> SaturatingCast<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<isize> for FixedU32<Frac>
source§fn saturating_cast(self) -> isize
fn saturating_cast(self) -> isize
source§impl<Frac: LeEqU32> SaturatingCast<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<u128> for FixedU32<Frac>
source§fn saturating_cast(self) -> u128
fn saturating_cast(self) -> u128
source§impl<Frac: LeEqU32> SaturatingCast<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<u16> for FixedU32<Frac>
source§fn saturating_cast(self) -> u16
fn saturating_cast(self) -> u16
source§impl<Frac: LeEqU32> SaturatingCast<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<u32> for FixedU32<Frac>
source§fn saturating_cast(self) -> u32
fn saturating_cast(self) -> u32
source§impl<Frac: LeEqU32> SaturatingCast<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<u64> for FixedU32<Frac>
source§fn saturating_cast(self) -> u64
fn saturating_cast(self) -> u64
source§impl<Frac: LeEqU32> SaturatingCast<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<u8> for FixedU32<Frac>
source§fn saturating_cast(self) -> u8
fn saturating_cast(self) -> u8
source§impl<Frac: LeEqU32> SaturatingCast<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingCast<usize> for FixedU32<Frac>
source§fn saturating_cast(self) -> usize
fn saturating_cast(self) -> usize
source§impl<Frac: LeEqU32> SaturatingMul for FixedU32<Frac>
impl<Frac: LeEqU32> SaturatingMul for FixedU32<Frac>
source§fn saturating_mul(&self, v: &Self) -> Self
fn saturating_mul(&self, v: &Self) -> Self
self * other
, saturating at the relevant high or low boundary of
the type.source§impl<Frac> SaturatingSub for FixedU32<Frac>
impl<Frac> SaturatingSub for FixedU32<Frac>
source§fn saturating_sub(&self, v: &Self) -> Self
fn saturating_sub(&self, v: &Self) -> Self
self - other
, saturating at the relevant high or low boundary of
the type.source§impl<Frac> ShlAssign<&i128> for FixedU32<Frac>
impl<Frac> ShlAssign<&i128> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &i128)
fn shl_assign(&mut self, rhs: &i128)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&i16> for FixedU32<Frac>
impl<Frac> ShlAssign<&i16> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &i16)
fn shl_assign(&mut self, rhs: &i16)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&i32> for FixedU32<Frac>
impl<Frac> ShlAssign<&i32> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &i32)
fn shl_assign(&mut self, rhs: &i32)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&i64> for FixedU32<Frac>
impl<Frac> ShlAssign<&i64> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &i64)
fn shl_assign(&mut self, rhs: &i64)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&i8> for FixedU32<Frac>
impl<Frac> ShlAssign<&i8> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &i8)
fn shl_assign(&mut self, rhs: &i8)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&isize> for FixedU32<Frac>
impl<Frac> ShlAssign<&isize> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &isize)
fn shl_assign(&mut self, rhs: &isize)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&u128> for FixedU32<Frac>
impl<Frac> ShlAssign<&u128> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &u128)
fn shl_assign(&mut self, rhs: &u128)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&u16> for FixedU32<Frac>
impl<Frac> ShlAssign<&u16> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &u16)
fn shl_assign(&mut self, rhs: &u16)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&u32> for FixedU32<Frac>
impl<Frac> ShlAssign<&u32> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &u32)
fn shl_assign(&mut self, rhs: &u32)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&u64> for FixedU32<Frac>
impl<Frac> ShlAssign<&u64> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &u64)
fn shl_assign(&mut self, rhs: &u64)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&u8> for FixedU32<Frac>
impl<Frac> ShlAssign<&u8> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &u8)
fn shl_assign(&mut self, rhs: &u8)
<<=
operation. Read moresource§impl<Frac> ShlAssign<&usize> for FixedU32<Frac>
impl<Frac> ShlAssign<&usize> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: &usize)
fn shl_assign(&mut self, rhs: &usize)
<<=
operation. Read moresource§impl<Frac> ShlAssign<i128> for FixedU32<Frac>
impl<Frac> ShlAssign<i128> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: i128)
fn shl_assign(&mut self, rhs: i128)
<<=
operation. Read moresource§impl<Frac> ShlAssign<i16> for FixedU32<Frac>
impl<Frac> ShlAssign<i16> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: i16)
fn shl_assign(&mut self, rhs: i16)
<<=
operation. Read moresource§impl<Frac> ShlAssign<i32> for FixedU32<Frac>
impl<Frac> ShlAssign<i32> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: i32)
fn shl_assign(&mut self, rhs: i32)
<<=
operation. Read moresource§impl<Frac> ShlAssign<i64> for FixedU32<Frac>
impl<Frac> ShlAssign<i64> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: i64)
fn shl_assign(&mut self, rhs: i64)
<<=
operation. Read moresource§impl<Frac> ShlAssign<i8> for FixedU32<Frac>
impl<Frac> ShlAssign<i8> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: i8)
fn shl_assign(&mut self, rhs: i8)
<<=
operation. Read moresource§impl<Frac> ShlAssign<isize> for FixedU32<Frac>
impl<Frac> ShlAssign<isize> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: isize)
fn shl_assign(&mut self, rhs: isize)
<<=
operation. Read moresource§impl<Frac> ShlAssign<u128> for FixedU32<Frac>
impl<Frac> ShlAssign<u128> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: u128)
fn shl_assign(&mut self, rhs: u128)
<<=
operation. Read moresource§impl<Frac> ShlAssign<u16> for FixedU32<Frac>
impl<Frac> ShlAssign<u16> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: u16)
fn shl_assign(&mut self, rhs: u16)
<<=
operation. Read moresource§impl<Frac> ShlAssign<u32> for FixedU32<Frac>
impl<Frac> ShlAssign<u32> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<=
operation. Read moresource§impl<Frac> ShlAssign<u64> for FixedU32<Frac>
impl<Frac> ShlAssign<u64> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: u64)
fn shl_assign(&mut self, rhs: u64)
<<=
operation. Read moresource§impl<Frac> ShlAssign<u8> for FixedU32<Frac>
impl<Frac> ShlAssign<u8> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: u8)
fn shl_assign(&mut self, rhs: u8)
<<=
operation. Read moresource§impl<Frac> ShlAssign<usize> for FixedU32<Frac>
impl<Frac> ShlAssign<usize> for FixedU32<Frac>
source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<=
operation. Read moresource§impl<Frac> ShrAssign<&i128> for FixedU32<Frac>
impl<Frac> ShrAssign<&i128> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &i128)
fn shr_assign(&mut self, rhs: &i128)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&i16> for FixedU32<Frac>
impl<Frac> ShrAssign<&i16> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &i16)
fn shr_assign(&mut self, rhs: &i16)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&i32> for FixedU32<Frac>
impl<Frac> ShrAssign<&i32> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &i32)
fn shr_assign(&mut self, rhs: &i32)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&i64> for FixedU32<Frac>
impl<Frac> ShrAssign<&i64> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &i64)
fn shr_assign(&mut self, rhs: &i64)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&i8> for FixedU32<Frac>
impl<Frac> ShrAssign<&i8> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &i8)
fn shr_assign(&mut self, rhs: &i8)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&isize> for FixedU32<Frac>
impl<Frac> ShrAssign<&isize> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &isize)
fn shr_assign(&mut self, rhs: &isize)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&u128> for FixedU32<Frac>
impl<Frac> ShrAssign<&u128> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &u128)
fn shr_assign(&mut self, rhs: &u128)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&u16> for FixedU32<Frac>
impl<Frac> ShrAssign<&u16> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &u16)
fn shr_assign(&mut self, rhs: &u16)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&u32> for FixedU32<Frac>
impl<Frac> ShrAssign<&u32> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &u32)
fn shr_assign(&mut self, rhs: &u32)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&u64> for FixedU32<Frac>
impl<Frac> ShrAssign<&u64> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &u64)
fn shr_assign(&mut self, rhs: &u64)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&u8> for FixedU32<Frac>
impl<Frac> ShrAssign<&u8> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &u8)
fn shr_assign(&mut self, rhs: &u8)
>>=
operation. Read moresource§impl<Frac> ShrAssign<&usize> for FixedU32<Frac>
impl<Frac> ShrAssign<&usize> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: &usize)
fn shr_assign(&mut self, rhs: &usize)
>>=
operation. Read moresource§impl<Frac> ShrAssign<i128> for FixedU32<Frac>
impl<Frac> ShrAssign<i128> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: i128)
fn shr_assign(&mut self, rhs: i128)
>>=
operation. Read moresource§impl<Frac> ShrAssign<i16> for FixedU32<Frac>
impl<Frac> ShrAssign<i16> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: i16)
fn shr_assign(&mut self, rhs: i16)
>>=
operation. Read moresource§impl<Frac> ShrAssign<i32> for FixedU32<Frac>
impl<Frac> ShrAssign<i32> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: i32)
fn shr_assign(&mut self, rhs: i32)
>>=
operation. Read moresource§impl<Frac> ShrAssign<i64> for FixedU32<Frac>
impl<Frac> ShrAssign<i64> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: i64)
fn shr_assign(&mut self, rhs: i64)
>>=
operation. Read moresource§impl<Frac> ShrAssign<i8> for FixedU32<Frac>
impl<Frac> ShrAssign<i8> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: i8)
fn shr_assign(&mut self, rhs: i8)
>>=
operation. Read moresource§impl<Frac> ShrAssign<isize> for FixedU32<Frac>
impl<Frac> ShrAssign<isize> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: isize)
fn shr_assign(&mut self, rhs: isize)
>>=
operation. Read moresource§impl<Frac> ShrAssign<u128> for FixedU32<Frac>
impl<Frac> ShrAssign<u128> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: u128)
fn shr_assign(&mut self, rhs: u128)
>>=
operation. Read moresource§impl<Frac> ShrAssign<u16> for FixedU32<Frac>
impl<Frac> ShrAssign<u16> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: u16)
fn shr_assign(&mut self, rhs: u16)
>>=
operation. Read moresource§impl<Frac> ShrAssign<u32> for FixedU32<Frac>
impl<Frac> ShrAssign<u32> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>=
operation. Read moresource§impl<Frac> ShrAssign<u64> for FixedU32<Frac>
impl<Frac> ShrAssign<u64> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: u64)
fn shr_assign(&mut self, rhs: u64)
>>=
operation. Read moresource§impl<Frac> ShrAssign<u8> for FixedU32<Frac>
impl<Frac> ShrAssign<u8> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: u8)
fn shr_assign(&mut self, rhs: u8)
>>=
operation. Read moresource§impl<Frac> ShrAssign<usize> for FixedU32<Frac>
impl<Frac> ShrAssign<usize> for FixedU32<Frac>
source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>=
operation. Read moresource§impl<Frac> SubAssign<&FixedU32<Frac>> for FixedU32<Frac>
impl<Frac> SubAssign<&FixedU32<Frac>> for FixedU32<Frac>
source§fn sub_assign(&mut self, rhs: &FixedU32<Frac>)
fn sub_assign(&mut self, rhs: &FixedU32<Frac>)
-=
operation. Read moresource§impl<Frac> SubAssign for FixedU32<Frac>
impl<Frac> SubAssign for FixedU32<Frac>
source§fn sub_assign(&mut self, rhs: FixedU32<Frac>)
fn sub_assign(&mut self, rhs: FixedU32<Frac>)
-=
operation. Read moresource§impl<Frac: LeEqU32> ToBytes for FixedU32<Frac>
impl<Frac: LeEqU32> ToBytes for FixedU32<Frac>
type Bytes = <FixedU32<Frac> as Fixed>::Bytes
source§fn to_be_bytes(&self) -> Self::Bytes
fn to_be_bytes(&self) -> Self::Bytes
source§fn to_le_bytes(&self) -> Self::Bytes
fn to_le_bytes(&self) -> Self::Bytes
source§fn to_ne_bytes(&self) -> Self::Bytes
fn to_ne_bytes(&self) -> Self::Bytes
source§impl<Frac: LeEqU32> ToFixed for FixedU32<Frac>
impl<Frac: LeEqU32> ToFixed for FixedU32<Frac>
source§fn to_fixed<F: Fixed>(self) -> F
fn to_fixed<F: Fixed>(self) -> F
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.
source§fn checked_to_fixed<F: Fixed>(self) -> Option<F>
fn checked_to_fixed<F: Fixed>(self) -> Option<F>
Converts a fixed-point number if it fits, otherwise returns None
.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn saturating_to_fixed<F: Fixed>(self) -> F
fn saturating_to_fixed<F: Fixed>(self) -> F
Converts a fixed-point number, saturating if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn wrapping_to_fixed<F: Fixed>(self) -> F
fn wrapping_to_fixed<F: Fixed>(self) -> F
Converts a fixed-point number, wrapping if it does not fit.
Any extra fractional bits are discarded, which rounds towards −∞.
source§fn overflowing_to_fixed<F: Fixed>(self) -> (F, bool)
fn overflowing_to_fixed<F: Fixed>(self) -> (F, bool)
source§fn unwrapped_to_fixed<F: Fixed>(self) -> F
fn unwrapped_to_fixed<F: Fixed>(self) -> F
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.
source§impl<Frac: LeEqU32> ToPrimitive for FixedU32<Frac>
impl<Frac: LeEqU32> ToPrimitive for FixedU32<Frac>
source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.source§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moresource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read moresource§impl<Frac: LeEqU32> TransparentWrapper<FixedU32<Frac>> for Unwrapped<FixedU32<Frac>>
impl<Frac: LeEqU32> TransparentWrapper<FixedU32<Frac>> for Unwrapped<FixedU32<Frac>>
source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
source§fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
source§impl<Frac: LeEqU32> TransparentWrapper<FixedU32<Frac>> for Wrapping<FixedU32<Frac>>
impl<Frac: LeEqU32> TransparentWrapper<FixedU32<Frac>> for Wrapping<FixedU32<Frac>>
source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
source§fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
source§impl<Frac> TransparentWrapper<u32> for FixedU32<Frac>
impl<Frac> TransparentWrapper<u32> for FixedU32<Frac>
source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
source§fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
source§impl<Frac: LeEqU32> UnwrappedCast<F128> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<F128> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> F128
fn unwrapped_cast(self) -> F128
source§impl<Frac: LeEqU32> UnwrappedCast<F128Bits> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<F128Bits> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> F128Bits
fn unwrapped_cast(self) -> F128Bits
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> UnwrappedCast<FixedI128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> UnwrappedCast<FixedI128<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedI128<FracDst>
fn unwrapped_cast(self) -> FixedI128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> UnwrappedCast<FixedI16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> UnwrappedCast<FixedI16<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedI16<FracDst>
fn unwrapped_cast(self) -> FixedI16<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedI32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedI32<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedI32<FracDst>
fn unwrapped_cast(self) -> FixedI32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> UnwrappedCast<FixedI64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> UnwrappedCast<FixedI64<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedI64<FracDst>
fn unwrapped_cast(self) -> FixedI64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> UnwrappedCast<FixedI8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> UnwrappedCast<FixedI8<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedI8<FracDst>
fn unwrapped_cast(self) -> FixedI8<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> UnwrappedCast<FixedU128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> UnwrappedCast<FixedU128<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU128<FracDst>
fn unwrapped_cast(self) -> FixedU128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> UnwrappedCast<FixedU16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> UnwrappedCast<FixedU16<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU16<FracDst>
fn unwrapped_cast(self) -> FixedU16<FracDst>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for F128
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for F128Bits
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for half_bf16
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for bool
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for bool
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for half_f16
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for f32
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for f64
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i128
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i128
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i16
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i16
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i32
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i32
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i64
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i64
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i8
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for i8
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for isize
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for isize
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u128
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u128
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u16
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u16
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u32
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u32
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u64
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u64
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u8
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for u8
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for usize
impl<Frac: LeEqU32> UnwrappedCast<FixedU32<Frac>> for usize
source§fn unwrapped_cast(self) -> FixedU32<Frac>
fn unwrapped_cast(self) -> FixedU32<Frac>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI128<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI16<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI64<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedI8<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU128<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU16<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU64<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> UnwrappedCast<FixedU32<FracDst>> for FixedU8<FracSrc>
source§fn unwrapped_cast(self) -> FixedU32<FracDst>
fn unwrapped_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> UnwrappedCast<FixedU64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> UnwrappedCast<FixedU64<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU64<FracDst>
fn unwrapped_cast(self) -> FixedU64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> UnwrappedCast<FixedU8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> UnwrappedCast<FixedU8<FracDst>> for FixedU32<FracSrc>
source§fn unwrapped_cast(self) -> FixedU8<FracDst>
fn unwrapped_cast(self) -> FixedU8<FracDst>
source§impl<Frac: LeEqU32> UnwrappedCast<bf16> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<bf16> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> half_bf16
fn unwrapped_cast(self) -> half_bf16
source§impl<Frac: LeEqU32> UnwrappedCast<f16> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<f16> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> half_f16
fn unwrapped_cast(self) -> half_f16
source§impl<Frac: LeEqU32> UnwrappedCast<f32> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<f32> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> f32
fn unwrapped_cast(self) -> f32
source§impl<Frac: LeEqU32> UnwrappedCast<f64> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<f64> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> f64
fn unwrapped_cast(self) -> f64
source§impl<Frac: LeEqU32> UnwrappedCast<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<i128> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> i128
fn unwrapped_cast(self) -> i128
source§impl<Frac: LeEqU32> UnwrappedCast<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<i16> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> i16
fn unwrapped_cast(self) -> i16
source§impl<Frac: LeEqU32> UnwrappedCast<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<i32> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> i32
fn unwrapped_cast(self) -> i32
source§impl<Frac: LeEqU32> UnwrappedCast<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<i64> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> i64
fn unwrapped_cast(self) -> i64
source§impl<Frac: LeEqU32> UnwrappedCast<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<i8> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> i8
fn unwrapped_cast(self) -> i8
source§impl<Frac: LeEqU32> UnwrappedCast<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<isize> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> isize
fn unwrapped_cast(self) -> isize
source§impl<Frac: LeEqU32> UnwrappedCast<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<u128> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> u128
fn unwrapped_cast(self) -> u128
source§impl<Frac: LeEqU32> UnwrappedCast<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<u16> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> u16
fn unwrapped_cast(self) -> u16
source§impl<Frac: LeEqU32> UnwrappedCast<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<u32> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> u32
fn unwrapped_cast(self) -> u32
source§impl<Frac: LeEqU32> UnwrappedCast<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<u64> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> u64
fn unwrapped_cast(self) -> u64
source§impl<Frac: LeEqU32> UnwrappedCast<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<u8> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> u8
fn unwrapped_cast(self) -> u8
source§impl<Frac: LeEqU32> UnwrappedCast<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> UnwrappedCast<usize> for FixedU32<Frac>
source§fn unwrapped_cast(self) -> usize
fn unwrapped_cast(self) -> usize
source§impl<Frac> WrappingAdd for FixedU32<Frac>
impl<Frac> WrappingAdd for FixedU32<Frac>
source§fn wrapping_add(&self, v: &Self) -> Self
fn wrapping_add(&self, v: &Self) -> Self
self + other
, wrapping around at the boundary of
the type.source§impl<Frac: LeEqU32> WrappingCast<F128> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<F128> for FixedU32<Frac>
source§fn wrapping_cast(self) -> F128
fn wrapping_cast(self) -> F128
source§impl<Frac: LeEqU32> WrappingCast<F128Bits> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<F128Bits> for FixedU32<Frac>
source§fn wrapping_cast(self) -> F128Bits
fn wrapping_cast(self) -> F128Bits
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> WrappingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> WrappingCast<FixedI128<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedI128<FracDst>
fn wrapping_cast(self) -> FixedI128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> WrappingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> WrappingCast<FixedI16<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedI16<FracDst>
fn wrapping_cast(self) -> FixedI16<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedI32<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedI32<FracDst>
fn wrapping_cast(self) -> FixedI32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> WrappingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> WrappingCast<FixedI64<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedI64<FracDst>
fn wrapping_cast(self) -> FixedI64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> WrappingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> WrappingCast<FixedI8<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedI8<FracDst>
fn wrapping_cast(self) -> FixedI8<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU128> WrappingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU128> WrappingCast<FixedU128<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedU128<FracDst>
fn wrapping_cast(self) -> FixedU128<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU16> WrappingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU16> WrappingCast<FixedU16<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedU16<FracDst>
fn wrapping_cast(self) -> FixedU16<FracDst>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for F128
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for F128
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for F128Bits
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for F128Bits
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for half_bf16
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for half_bf16
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for bool
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for bool
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for half_f16
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for half_f16
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for f32
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for f32
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for f64
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for f64
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i128
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i128
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i16
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i16
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i32
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i32
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i64
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i64
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i8
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for i8
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for isize
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for isize
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u128
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u128
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u16
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u16
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u32
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u32
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u64
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u64
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u8
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for u8
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for usize
impl<Frac: LeEqU32> WrappingCast<FixedU32<Frac>> for usize
source§fn wrapping_cast(self) -> FixedU32<Frac>
fn wrapping_cast(self) -> FixedU32<Frac>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI128<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI16<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI32<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI64<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedI8<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU128, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
impl<FracSrc: LeEqU128, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU128<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU16, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
impl<FracSrc: LeEqU16, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU16<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU64, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
impl<FracSrc: LeEqU64, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU64<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU8, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
impl<FracSrc: LeEqU8, FracDst: LeEqU32> WrappingCast<FixedU32<FracDst>> for FixedU8<FracSrc>
source§fn wrapping_cast(self) -> FixedU32<FracDst>
fn wrapping_cast(self) -> FixedU32<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU64> WrappingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU64> WrappingCast<FixedU64<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedU64<FracDst>
fn wrapping_cast(self) -> FixedU64<FracDst>
source§impl<FracSrc: LeEqU32, FracDst: LeEqU8> WrappingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
impl<FracSrc: LeEqU32, FracDst: LeEqU8> WrappingCast<FixedU8<FracDst>> for FixedU32<FracSrc>
source§fn wrapping_cast(self) -> FixedU8<FracDst>
fn wrapping_cast(self) -> FixedU8<FracDst>
source§impl<Frac: LeEqU32> WrappingCast<bf16> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<bf16> for FixedU32<Frac>
source§fn wrapping_cast(self) -> half_bf16
fn wrapping_cast(self) -> half_bf16
source§impl<Frac: LeEqU32> WrappingCast<f16> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<f16> for FixedU32<Frac>
source§fn wrapping_cast(self) -> half_f16
fn wrapping_cast(self) -> half_f16
source§impl<Frac: LeEqU32> WrappingCast<f32> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<f32> for FixedU32<Frac>
source§fn wrapping_cast(self) -> f32
fn wrapping_cast(self) -> f32
source§impl<Frac: LeEqU32> WrappingCast<f64> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<f64> for FixedU32<Frac>
source§fn wrapping_cast(self) -> f64
fn wrapping_cast(self) -> f64
source§impl<Frac: LeEqU32> WrappingCast<i128> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<i128> for FixedU32<Frac>
source§fn wrapping_cast(self) -> i128
fn wrapping_cast(self) -> i128
source§impl<Frac: LeEqU32> WrappingCast<i16> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<i16> for FixedU32<Frac>
source§fn wrapping_cast(self) -> i16
fn wrapping_cast(self) -> i16
source§impl<Frac: LeEqU32> WrappingCast<i32> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<i32> for FixedU32<Frac>
source§fn wrapping_cast(self) -> i32
fn wrapping_cast(self) -> i32
source§impl<Frac: LeEqU32> WrappingCast<i64> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<i64> for FixedU32<Frac>
source§fn wrapping_cast(self) -> i64
fn wrapping_cast(self) -> i64
source§impl<Frac: LeEqU32> WrappingCast<i8> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<i8> for FixedU32<Frac>
source§fn wrapping_cast(self) -> i8
fn wrapping_cast(self) -> i8
source§impl<Frac: LeEqU32> WrappingCast<isize> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<isize> for FixedU32<Frac>
source§fn wrapping_cast(self) -> isize
fn wrapping_cast(self) -> isize
source§impl<Frac: LeEqU32> WrappingCast<u128> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<u128> for FixedU32<Frac>
source§fn wrapping_cast(self) -> u128
fn wrapping_cast(self) -> u128
source§impl<Frac: LeEqU32> WrappingCast<u16> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<u16> for FixedU32<Frac>
source§fn wrapping_cast(self) -> u16
fn wrapping_cast(self) -> u16
source§impl<Frac: LeEqU32> WrappingCast<u32> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<u32> for FixedU32<Frac>
source§fn wrapping_cast(self) -> u32
fn wrapping_cast(self) -> u32
source§impl<Frac: LeEqU32> WrappingCast<u64> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<u64> for FixedU32<Frac>
source§fn wrapping_cast(self) -> u64
fn wrapping_cast(self) -> u64
source§impl<Frac: LeEqU32> WrappingCast<u8> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<u8> for FixedU32<Frac>
source§fn wrapping_cast(self) -> u8
fn wrapping_cast(self) -> u8
source§impl<Frac: LeEqU32> WrappingCast<usize> for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingCast<usize> for FixedU32<Frac>
source§fn wrapping_cast(self) -> usize
fn wrapping_cast(self) -> usize
source§impl<Frac: LeEqU32> WrappingMul for FixedU32<Frac>
impl<Frac: LeEqU32> WrappingMul for FixedU32<Frac>
source§fn wrapping_mul(&self, v: &Self) -> Self
fn wrapping_mul(&self, v: &Self) -> Self
self * other
, wrapping around at the boundary
of the type.source§impl<Frac> WrappingNeg for FixedU32<Frac>
impl<Frac> WrappingNeg for FixedU32<Frac>
source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self
,
wrapping around at the boundary of the type. Read moresource§impl<Frac> WrappingShl for FixedU32<Frac>
impl<Frac> WrappingShl for FixedU32<Frac>
source§fn wrapping_shl(&self, rhs: u32) -> Self
fn wrapping_shl(&self, rhs: u32) -> Self
self << mask(rhs)
,
where mask
removes any high order bits of rhs
that would
cause the shift to exceed the bitwidth of the type. Read moresource§impl<Frac> WrappingShr for FixedU32<Frac>
impl<Frac> WrappingShr for FixedU32<Frac>
source§fn wrapping_shr(&self, rhs: u32) -> Self
fn wrapping_shr(&self, rhs: u32) -> Self
self >> mask(rhs)
,
where mask
removes any high order bits of rhs
that would
cause the shift to exceed the bitwidth of the type. Read moresource§impl<Frac> WrappingSub for FixedU32<Frac>
impl<Frac> WrappingSub for FixedU32<Frac>
source§fn wrapping_sub(&self, v: &Self) -> Self
fn wrapping_sub(&self, v: &Self) -> Self
self - other
, wrapping around at the boundary
of the type.impl<Frac> Copy for FixedU32<Frac>
impl<Frac: Unsigned> Eq for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalArbitrary for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalBorsh for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalFeatures for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalNightlyFloat for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalNum for FixedU32<Frac>
impl<Frac: LeEqU32> FixedOptionalSerde for FixedU32<Frac>
impl<Frac: 'static> Pod for FixedU32<Frac>
impl<Frac> Unsigned for FixedU32<Frac>
Auto Trait Implementations§
impl<Frac> Freeze for FixedU32<Frac>
impl<Frac> RefUnwindSafe for FixedU32<Frac>where
Frac: RefUnwindSafe,
impl<Frac> Send for FixedU32<Frac>where
Frac: Send,
impl<Frac> Sync for FixedU32<Frac>where
Frac: Sync,
impl<Frac> Unpin for FixedU32<Frac>where
Frac: Unpin,
impl<Frac> UnwindSafe for FixedU32<Frac>where
Frac: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)