pub trait Num:
Clone
+ Copy
+ Debug
+ Eq
+ Ord
+ PartialEq
+ PartialOrd
+ Sized {
type Raw: Num<Raw = Self::Raw> + Shl<u32, Output = Self::Raw> + Shr<u32, Output = Self::Raw>;
type Output<const B: u32, const S: i32>: Num<Raw = Self::Raw>;
const BITS: u32;
const SHIFT: i32;
const MIN: Self;
const MAX: Self;
const SIGNED: bool;
Show 19 methods
// Required methods
unsafe fn new_unchecked(val: Self::Raw) -> Self;
fn raw(self) -> Self::Raw;
unsafe fn from_f32_unchecked(val: f32) -> Self;
unsafe fn from_f64_unchecked(val: f64) -> Self;
fn into_f32(self) -> f32;
fn into_f64(self) -> f64;
// Provided methods
fn new(val: Self::Raw) -> Result<Self, RangeError> { ... }
fn from_f32(val: f32) -> Result<Self, RangeError> { ... }
fn from_f64(val: f64) -> Result<Self, RangeError> { ... }
fn from_fp<T: Num, F: Num<Raw = T>>(val: F) -> Self
where Self::Raw: TryFrom<T> { ... }
fn into_fp<T, F: Num<Raw = T>>(self) -> F
where T: TryFrom<Self::Raw> + Num { ... }
fn add_bits<const N: u32>(self) -> Self::Output<{ _ }, { Self::SHIFT }>
where [(); { _ }]: { ... }
fn set_bits<const N: u32>(
self,
) -> Result<Self::Output<N, { Self::SHIFT }>, RangeError> { ... }
unsafe fn set_bits_unchecked<const N: u32>(
self,
) -> Self::Output<N, { Self::SHIFT }> { ... }
fn saturate<const N: u32>(self) -> Self::Output<N, { Self::SHIFT }> { ... }
fn logical_shl<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
where [(); { _ }]: { ... }
fn logical_shr<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
where [(); { _ }]: { ... }
fn raw_shl<const N: u32>(self) -> Self::Output<{ _ }, { _ }>
where [(); { _ }]: { ... }
fn raw_shr<const N: u32>(self) -> Self::Output<{ _ }, { _ }>
where [(); { _ }]: { ... }
}
Expand description
A fixed-point number, stored as type Raw
,
where only the BITS
least-significant bits may be nonzero.
The raw value is divided by 2.pow(SHIFT)
to obtain the logical value.
Required Associated Constants§
Sourceconst BITS: u32
const BITS: u32
BITS
is the number of least-significant bits which are permitted to vary.
The Raw::BITS - BITS
high-order bits must be zero (for unsigned Raw
) or the
same as the high bit of the lower BITS
bits (for signed Raw
).
Sourceconst SHIFT: i32
const SHIFT: i32
SHIFT
sets the scaling factor between the stored raw value (of type Raw
)
and the “logical” value with it represents. The logical value of this
fixed-point number is equal to the raw value divided by 2.pow(SHIFT)
.
In other words, positive SHIFT
means that the logical value consists of
BITS - SHIFT
integer bits followed by SHIFT
fractional bits, and negative
shift means that the logical value consists of BITS - SHIFT
integer bits
(of which the last -SHIFT
bits are zero).
Required Associated Types§
Required Methods§
Sourceunsafe fn new_unchecked(val: Self::Raw) -> Self
unsafe fn new_unchecked(val: Self::Raw) -> Self
Interpret the provided raw value as a fixed-point number of type Self
.
Unsafe: no bounds checking is performed; the caller must ensure that the
result lies between Self::MIN
and Self::MAX
. It is almost always better
to use .new().unwrap()
instead of this function, so that an out-of-bounds
value panics with a reasonable message instead of propagating undefined
behavior.
Sourcefn raw(self) -> Self::Raw
fn raw(self) -> Self::Raw
Return the raw value which internally represents this fixed-point number.
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
Provided Methods§
Sourcefn new(val: Self::Raw) -> Result<Self, RangeError>
fn new(val: Self::Raw) -> Result<Self, RangeError>
Interpret the provided raw value as a fixed-point number of type Self
,
or return a RangeError
if it is too small or too large to represent
a valid instance of Self
.
Examples found in repository?
6fn main() {
7 // There are many ways to create a new fixed-point number
8 let options: [fp::I32<10, 5>; 4] = [
9 fp::I32::from_f32(3.125).unwrap(),
10 fp::I32::from_f64(3.125).unwrap(),
11 fp::I32::new(100).unwrap(),
12 100i32.logical_shr::<5>().set_bits().unwrap(),
13 ];
14 assert!(options.iter().min() == options.iter().max()); // all equal
15
16 // Arithmetic works pretty much seamlessly
17 let a = 12i32.set_bits::<5>().unwrap();
18 let b = (-1i32).set_bits::<1>().unwrap();
19 let _ = a + b; // type is I32<6, 0>
20
21 // Addition is associative in value, but not in type
22 let _: fp::I32<6, 0> = a + (b + b);
23 let _: fp::I32<7, 0> = (a + b) + b;
24
25 let x = fp::I32::<21, 20>::from_f32(0.497).unwrap();
26 let y = x / fp::I32::<32, 0>::new(12).unwrap();
27 let z = x + (-y);
28 println!("{} {}", x.raw(), x.into_f64());
29 println!("{} {}", z.raw(), z.into_f64());
30}
Sourcefn from_f32(val: f32) -> Result<Self, RangeError>
fn from_f32(val: f32) -> Result<Self, RangeError>
Return the fixed-point number of type Self
which has a logical value of val
,
or return a RangeError if val
is too small or too large to be represented
by Self
.
Examples found in repository?
6fn main() {
7 // There are many ways to create a new fixed-point number
8 let options: [fp::I32<10, 5>; 4] = [
9 fp::I32::from_f32(3.125).unwrap(),
10 fp::I32::from_f64(3.125).unwrap(),
11 fp::I32::new(100).unwrap(),
12 100i32.logical_shr::<5>().set_bits().unwrap(),
13 ];
14 assert!(options.iter().min() == options.iter().max()); // all equal
15
16 // Arithmetic works pretty much seamlessly
17 let a = 12i32.set_bits::<5>().unwrap();
18 let b = (-1i32).set_bits::<1>().unwrap();
19 let _ = a + b; // type is I32<6, 0>
20
21 // Addition is associative in value, but not in type
22 let _: fp::I32<6, 0> = a + (b + b);
23 let _: fp::I32<7, 0> = (a + b) + b;
24
25 let x = fp::I32::<21, 20>::from_f32(0.497).unwrap();
26 let y = x / fp::I32::<32, 0>::new(12).unwrap();
27 let z = x + (-y);
28 println!("{} {}", x.raw(), x.into_f64());
29 println!("{} {}", z.raw(), z.into_f64());
30}
Sourcefn from_f64(val: f64) -> Result<Self, RangeError>
fn from_f64(val: f64) -> Result<Self, RangeError>
Return the fixed-point number of type Self
which has a logical value of val
,
or return a RangeError if val
is too small or too large to be represented
by Self
.
Examples found in repository?
6fn main() {
7 // There are many ways to create a new fixed-point number
8 let options: [fp::I32<10, 5>; 4] = [
9 fp::I32::from_f32(3.125).unwrap(),
10 fp::I32::from_f64(3.125).unwrap(),
11 fp::I32::new(100).unwrap(),
12 100i32.logical_shr::<5>().set_bits().unwrap(),
13 ];
14 assert!(options.iter().min() == options.iter().max()); // all equal
15
16 // Arithmetic works pretty much seamlessly
17 let a = 12i32.set_bits::<5>().unwrap();
18 let b = (-1i32).set_bits::<1>().unwrap();
19 let _ = a + b; // type is I32<6, 0>
20
21 // Addition is associative in value, but not in type
22 let _: fp::I32<6, 0> = a + (b + b);
23 let _: fp::I32<7, 0> = (a + b) + b;
24
25 let x = fp::I32::<21, 20>::from_f32(0.497).unwrap();
26 let y = x / fp::I32::<32, 0>::new(12).unwrap();
27 let z = x + (-y);
28 println!("{} {}", x.raw(), x.into_f64());
29 println!("{} {}", z.raw(), z.into_f64());
30}
Sourcefn from_fp<T: Num, F: Num<Raw = T>>(val: F) -> Self
fn from_fp<T: Num, F: Num<Raw = T>>(val: F) -> Self
Return the fixed-point number of type Self
which has the same logical value as val
.
F
and Self
must have the same shift and signedness. Self
must have at least as
many bits as F
.
Sourcefn into_fp<T, F: Num<Raw = T>>(self) -> F
fn into_fp<T, F: Num<Raw = T>>(self) -> F
Return the fixed-point number of type F
which has the same logical value as self
.
F
and Self
must have the same shift and signedness. F
must have at least as
many bits as Self
.
Sourcefn add_bits<const N: u32>(self) -> Self::Output<{ _ }, { Self::SHIFT }>
fn add_bits<const N: u32>(self) -> Self::Output<{ _ }, { Self::SHIFT }>
Increase the number of bits used to represent this value. Both the raw and logical values are unchanged. This is a type system operation only. Compilation will fail if the new number of bits is too large for the raw type.
Sourcefn set_bits<const N: u32>(
self,
) -> Result<Self::Output<N, { Self::SHIFT }>, RangeError>
fn set_bits<const N: u32>( self, ) -> Result<Self::Output<N, { Self::SHIFT }>, RangeError>
Set the number of bits used to represent this value. The value is checked at runtime to ensure it is in range for the new number of bits. If succesful, both the raw and logical values are unchanged.
Examples found in repository?
6fn main() {
7 // There are many ways to create a new fixed-point number
8 let options: [fp::I32<10, 5>; 4] = [
9 fp::I32::from_f32(3.125).unwrap(),
10 fp::I32::from_f64(3.125).unwrap(),
11 fp::I32::new(100).unwrap(),
12 100i32.logical_shr::<5>().set_bits().unwrap(),
13 ];
14 assert!(options.iter().min() == options.iter().max()); // all equal
15
16 // Arithmetic works pretty much seamlessly
17 let a = 12i32.set_bits::<5>().unwrap();
18 let b = (-1i32).set_bits::<1>().unwrap();
19 let _ = a + b; // type is I32<6, 0>
20
21 // Addition is associative in value, but not in type
22 let _: fp::I32<6, 0> = a + (b + b);
23 let _: fp::I32<7, 0> = (a + b) + b;
24
25 let x = fp::I32::<21, 20>::from_f32(0.497).unwrap();
26 let y = x / fp::I32::<32, 0>::new(12).unwrap();
27 let z = x + (-y);
28 println!("{} {}", x.raw(), x.into_f64());
29 println!("{} {}", z.raw(), z.into_f64());
30}
Sourceunsafe fn set_bits_unchecked<const N: u32>(
self,
) -> Self::Output<N, { Self::SHIFT }>
unsafe fn set_bits_unchecked<const N: u32>( self, ) -> Self::Output<N, { Self::SHIFT }>
Set the number of bits used to represent this value. Unsafe: no bounds checking
is performed; the caller must ensure that the value fits within
the new number of bits. It is almost always better to call .set_bits().unwrap()
instead, so that an out-of-bounds
value panics with a reasonable message instead of propagating undefined
behavior.
Sourcefn saturate<const N: u32>(self) -> Self::Output<N, { Self::SHIFT }>
fn saturate<const N: u32>(self) -> Self::Output<N, { Self::SHIFT }>
Set the number of bits used to represent this value, saturating in case of overflow.
Sourcefn logical_shl<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
fn logical_shl<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
Shift the logical value of this number left by N bits. (N may be negative for a right shift). This is a type system operation only; the raw value is unchanged. The logical value is multiplied by 2^N.
Sourcefn logical_shr<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
fn logical_shr<const N: i32>(self) -> Self::Output<{ Self::BITS }, { _ }>
Shift the logical value of this number right by N bits. (N may be negative for a left shift). This is a type system operation only; the raw value is unchanged. The logical value is divided by 2^N.
Examples found in repository?
6fn main() {
7 // There are many ways to create a new fixed-point number
8 let options: [fp::I32<10, 5>; 4] = [
9 fp::I32::from_f32(3.125).unwrap(),
10 fp::I32::from_f64(3.125).unwrap(),
11 fp::I32::new(100).unwrap(),
12 100i32.logical_shr::<5>().set_bits().unwrap(),
13 ];
14 assert!(options.iter().min() == options.iter().max()); // all equal
15
16 // Arithmetic works pretty much seamlessly
17 let a = 12i32.set_bits::<5>().unwrap();
18 let b = (-1i32).set_bits::<1>().unwrap();
19 let _ = a + b; // type is I32<6, 0>
20
21 // Addition is associative in value, but not in type
22 let _: fp::I32<6, 0> = a + (b + b);
23 let _: fp::I32<7, 0> = (a + b) + b;
24
25 let x = fp::I32::<21, 20>::from_f32(0.497).unwrap();
26 let y = x / fp::I32::<32, 0>::new(12).unwrap();
27 let z = x + (-y);
28 println!("{} {}", x.raw(), x.into_f64());
29 println!("{} {}", z.raw(), z.into_f64());
30}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Num for i8
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for i8
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 8u32
const SHIFT: i32 = 0i32
const MIN: i8 = -128i8
const MAX: i8 = 127i8
const SIGNED: bool = true
type Raw = i8
type Output<const B: u32, const S: i32> = I8<B, S>
unsafe fn new_unchecked(val: i8) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> i8
Source§impl Num for i16
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for i16
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 16u32
const SHIFT: i32 = 0i32
const MIN: i16 = -32_768i16
const MAX: i16 = 32_767i16
const SIGNED: bool = true
type Raw = i16
type Output<const B: u32, const S: i32> = I16<B, S>
unsafe fn new_unchecked(val: i16) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> i16
Source§impl Num for i32
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for i32
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 32u32
const SHIFT: i32 = 0i32
const MIN: i32 = -2_147_483_648i32
const MAX: i32 = 2_147_483_647i32
const SIGNED: bool = true
type Raw = i32
type Output<const B: u32, const S: i32> = I32<B, S>
unsafe fn new_unchecked(val: i32) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> i32
Source§impl Num for i64
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for i64
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 64u32
const SHIFT: i32 = 0i32
const MIN: i64 = -9_223_372_036_854_775_808i64
const MAX: i64 = 9_223_372_036_854_775_807i64
const SIGNED: bool = true
type Raw = i64
type Output<const B: u32, const S: i32> = I64<B, S>
unsafe fn new_unchecked(val: i64) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> i64
Source§impl Num for i128
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for i128
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 128u32
const SHIFT: i32 = 0i32
const MIN: i128 = -170_141_183_460_469_231_731_687_303_715_884_105_728i128
const MAX: i128 = 170_141_183_460_469_231_731_687_303_715_884_105_727i128
const SIGNED: bool = true
type Raw = i128
type Output<const B: u32, const S: i32> = I128<B, S>
unsafe fn new_unchecked(val: i128) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> i128
Source§impl Num for isize
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for isize
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 32u32
const SHIFT: i32 = 0i32
const MIN: isize = -2_147_483_648isize
const MAX: isize = 2_147_483_647isize
const SIGNED: bool = true
type Raw = isize
type Output<const B: u32, const S: i32> = Isize<B, S>
unsafe fn new_unchecked(val: isize) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> isize
Source§impl Num for u8
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for u8
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 8u32
const SHIFT: i32 = 0i32
const MIN: u8 = 0u8
const MAX: u8 = 255u8
const SIGNED: bool = false
type Raw = u8
type Output<const B: u32, const S: i32> = U8<B, S>
unsafe fn new_unchecked(val: u8) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> u8
Source§impl Num for u16
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for u16
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 16u32
const SHIFT: i32 = 0i32
const MIN: u16 = 0u16
const MAX: u16 = 65_535u16
const SIGNED: bool = false
type Raw = u16
type Output<const B: u32, const S: i32> = U16<B, S>
unsafe fn new_unchecked(val: u16) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> u16
Source§impl Num for u32
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for u32
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 32u32
const SHIFT: i32 = 0i32
const MIN: u32 = 0u32
const MAX: u32 = 4_294_967_295u32
const SIGNED: bool = false
type Raw = u32
type Output<const B: u32, const S: i32> = U32<B, S>
unsafe fn new_unchecked(val: u32) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> u32
Source§impl Num for u64
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for u64
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 64u32
const SHIFT: i32 = 0i32
const MIN: u64 = 0u64
const MAX: u64 = 18_446_744_073_709_551_615u64
const SIGNED: bool = false
type Raw = u64
type Output<const B: u32, const S: i32> = U64<B, S>
unsafe fn new_unchecked(val: u64) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> u64
Source§impl Num for u128
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for u128
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.
const BITS: u32 = 128u32
const SHIFT: i32 = 0i32
const MIN: u128 = 0u128
const MAX: u128 = 340_282_366_920_938_463_463_374_607_431_768_211_455u128
const SIGNED: bool = false
type Raw = u128
type Output<const B: u32, const S: i32> = U128<B, S>
unsafe fn new_unchecked(val: u128) -> Self
unsafe fn from_f32_unchecked(val: f32) -> Self
unsafe fn from_f64_unchecked(val: f64) -> Self
fn raw(self) -> u128
Source§impl Num for usize
Every integer is also a fixed-point number, considered to have
the maximum number of bits and zero shift.
impl Num for usize
Every integer is also a fixed-point number, considered to have the maximum number of bits and zero shift.
Source§fn into_f32(self) -> f32
fn into_f32(self) -> f32
Conversion to f32 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 24 bits wide.
Source§fn into_f64(self) -> f64
fn into_f64(self) -> f64
Conversion to f64 is guaranteed to be exact. Therefore, this function only works for integer types which are no more than 53 bits wide.