Struct VaxFloatingPoint

Source
pub struct VaxFloatingPoint<T> { /* private fields */ }
Expand description

Intermediate floating-point type used to perform arithmetic operations for the VAX floating-point types.

§Floating-point Type Differences between VAX and IEEE 754

  • The VAX uses a unique byte ordering for the floating-point values. Each set of 16-bit values is in little endian order, but the 16-bit byte-pairs are in big-endian order. The first (lowest address) 16-bits of the VAX floating-point types contain the sign bit, the exponent, and, usually, the most significant bits of the fraction. The last (highest addressed) 16-bits of the VAX floating-point types contain the least significant bits of the fraction.
  • The VAX doesn’t support negative zero. An exponent value of zero with a sign bit of 1 is a reserved value and would trigger a reserved operand fault.
  • The VAX doesn’t support subnormal numbers. All values with a sign bit clear and a exponent value of zero are considered to be zero.
  • The VAX doesn’t have an Infinity value, which gives it one more exponent value.
  • The VAX exponent bias is 2 more than the ones used in IEEE 754. Since VAX doesn’t support an infinity state, it has symetrical exponent values. For example, the F_floating type has an exponent range from 127 to -127, whereas, the single-precision floating-point type defined in IEEE 754 has an exponent range from 128 to -125. (see note about differences between exponents referred to in this documentation and how it is referenced to by Wikipedia)
  • The VAX rounds differently than Rust. The VAX always rounds ties up, whereas, the f32 and f64 types round according to the roundTiesToEven direction defined in IEEE 754-2008.

§Notes

§Wikipedia Exponents

There is a difference between the exponent values in the Wikipedia reference documentation for IEEE 754, and exponent values in this documentation, the VAX documentation, and as defined in Rust as the MIN_EXP and MAX_EXP values in f32 and f64).

It comes down to how the implicit bit in the fraction portion of the floating-point is treated. In Wikipedia, the implicit bit is the least-significant non-fractional bit, and here it is the most-significant fractional bit.

On Wikipedia, the range for values with exponent 0 is ≥ 1.0 and < 2.0. Here, the range for exponent 0 is ≥ 0.5 and < 1.0. Therefore, our exponent 0 is equal to Wikipedia’s exponent -1.

Implementations§

Source§

impl<T: Copy + PartialOrd> VaxFloatingPoint<T>

Source

pub const fn sign(&self) -> Sign

Return the Sign of the VaxFloatingPoint.

§Examples
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-1.0).sign(), Sign::Negative);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0).sign(), Sign::Positive);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(1.0).sign(), Sign::Positive);
// Zero is always positive, because VaxFloatingPoint doesn't support negative zero.
assert_eq!(VaxFloatingPoint::<u64>::from_f64(-0.0).sign(), Sign::Positive);
Source

pub const fn exponent(&self) -> i32

Return the exponent of the VaxFloatingPoint.

§Examples
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-1.0).exponent(), 1);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.5).exponent(), 0);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.25).exponent(), -1);
Source

pub const fn fraction(&self) -> T

Return the fraction of the VaxFloatingPoint.

§Examples
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-1.0).fraction(), 1 << 31);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.5).fraction(), 1 << 63);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0).fraction(), 0);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.25).fraction(), 1 << 127);
Source

pub const fn fault(&self) -> Option<Fault>

Return the fault of the VaxFloatingPoint.

§Examples
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-1.0).fault(), None);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(f32::INFINITY).fault(),
    Some(Fault::DivByZero));
assert_eq!(VaxFloatingPoint::<u64>::from_f32(f32::NAN).fault(),
    Some(Fault::Reserved));
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.25).fault(), None);
Source

pub const fn is_error(&self) -> bool

Return true if the fault is not None of the VaxFloatingPoint.

§Examples
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-1.0).is_error(), false);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(f32::INFINITY).is_error(), true);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(f32::NAN).is_error(), true);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.25).is_error(), false);
Source

pub const fn shift_left(self, shift: i32) -> Self

Multiply the VaxFloatingPoint by 2shift.

§Examples
for (start, shift, result) in [
    (-1.0, -1, -0.5),
    (0.5, 1, 1.0),
    (2048.0, -11, 1.0),
    (2.0, 10, 2048.0),
].iter() {
    assert_eq!(VaxFloatingPoint::<u32>::from_f32(*start).shift_left(*shift),
        VaxFloatingPoint::<u32>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u64>::from_f32(*start).shift_left(*shift),
        VaxFloatingPoint::<u64>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u128>::from_f32(*start).shift_left(*shift),
        VaxFloatingPoint::<u128>::from_f32(*result));
}
Source

pub const fn shift_right(self, shift: i32) -> Self

Divide the VaxFloatingPoint by 2shift.

§Examples
for (start, shift, result) in [
    (-1.0, 1, -0.5),
    (0.5, 1, 0.25),
    (1024.0, 10, 1.0),
].iter() {
    assert_eq!(VaxFloatingPoint::<u32>::from_f32(*start).shift_right(*shift),
        VaxFloatingPoint::<u32>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u64>::from_f32(*start).shift_right(*shift),
        VaxFloatingPoint::<u64>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u128>::from_f32(*start).shift_right(*shift),
        VaxFloatingPoint::<u128>::from_f32(*result));
}
Source

pub const fn shift_left_unsigned(self, shift: u32) -> Self

Multiply the VaxFloatingPoint by 2shift.

§Examples
for (start, shift, result) in [
    (-1.0, 1, -2.0),
    (0.5, 1, 1.0),
    (2.0, 10, 2048.0),
].iter() {
    assert_eq!(VaxFloatingPoint::<u32>::from_f32(*start).shift_left_unsigned(*shift),
        VaxFloatingPoint::<u32>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u64>::from_f32(*start).shift_left_unsigned(*shift),
        VaxFloatingPoint::<u64>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u128>::from_f32(*start).shift_left_unsigned(*shift),
        VaxFloatingPoint::<u128>::from_f32(*result));
}
Source

pub const fn shift_right_unsigned(self, shift: u32) -> Self

Divide the VaxFloatingPoint by 2shift.

§Examples
for (start, shift, result) in [
    (-1.0, 1, -0.5),
    (0.5, 1, 0.25),
    (1024.0, 10, 1.0),
].iter() {
    assert_eq!(VaxFloatingPoint::<u32>::from_f32(*start).shift_right_unsigned(*shift),
        VaxFloatingPoint::<u32>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u64>::from_f32(*start).shift_right_unsigned(*shift),
        VaxFloatingPoint::<u64>::from_f32(*result));
    assert_eq!(VaxFloatingPoint::<u128>::from_f32(*start).shift_right_unsigned(*shift),
        VaxFloatingPoint::<u128>::from_f32(*result));
}
Source§

impl VaxFloatingPoint<u32>

Source

pub const FRAC_HIGH_BIT: u32 = 2_147_483_648u32

Mask with the most significant bit of the VaxFloatingPoint<u32> fraction value set.

Source

pub const DIGITS: u32 = 9u32

Approximate number of significant digits in base 10.

Source

pub const ZERO: Self

A VaxFloatingPoint<u32> equal to zero.

Source

pub const fn new(sign: Sign, exp: i32, frac: u32) -> Self

Create a new VaxFloatingPoint<u32> from the sign, exponent, and fraction.

It expects a normalized the fraction value.

§Examples
type VFP = VaxFloatingPoint<u32>;
assert_eq!(VFP::new(Sign::Positive, 0, 0), VFP::ZERO);
assert_eq!(VFP::new(Sign::Positive, 0, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.5));
assert_eq!(VFP::new(Sign::Positive, 1, VFP::FRAC_HIGH_BIT), VFP::from_f32(1.0));
assert_eq!(VFP::new(Sign::Positive, -2, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.125));
Source

pub const fn from_fault(fault: Fault) -> Self

Create a new VaxFloatingPoint<u32> in a fault state.

§Examples
type VFP = VaxFloatingPoint<u32>;
assert_eq!(VFP::from_fault(Fault::DivByZero).fault(), Some(Fault::DivByZero));
assert_eq!(VFP::from_fault(Fault::Reserved).fault(), Some(Fault::Reserved));
assert_eq!(VFP::from_fault(Fault::Overflow).fault(), Some(Fault::Overflow));
assert_eq!(VFP::from_fault(Fault::Underflow).fault(), Some(Fault::Underflow));
Source

pub const fn is_zero(&self) -> bool

Check to see if the value is zero.

§Examples
type VFP = VaxFloatingPoint<u32>;

for case in [
    1.0_f32,
    123.456,
    -300.0
].iter() {
    assert_eq!(VFP::from_f32(*case).is_zero(), false);
}
assert_eq!(VFP::ZERO.is_zero(), true);
Source

pub const fn negate(self) -> Self

Negate the VaxFloatingPoint value.

§Examples
type VFP = VaxFloatingPoint<u32>;

for (case, neg) in [
    (1.0, -1.0),
    (-1.0, 1.0),
    (123.456, -123.456),
    (-300.0, 300.0),
].iter() {
    assert_eq!(VFP::from_f32(*case).negate(), VFP::from_f32(*neg));
}
assert_eq!(VFP::ZERO.negate(), VFP::ZERO);
Source

pub const fn add_to(self, other: Self, sub: bool) -> Self

Add (or subtract) two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u32>;

for (a, b, add, sub) in [
    (1.0, 0.0, 1.0, 1.0),
    (0.0, 1.0, 1.0, -1.0),
    (1.0, 1.0, 2.0, 0.0),
    (2.5, 1.0, 3.5, 1.5),
    (2.5, 3.0, 5.5, -0.5),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.add_to(fp2, false).to_f32(), *add);
    assert_eq!(fp1.add_to(fp2, true).to_f32(), *sub);
}
Source

pub const fn multiply_by(self, multiplier: Self) -> Self

Multiply two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u32>;

for (a, b, quo) in [
    (1.0, 0.0, 0.0),
    (0.0, 1.0, 0.0),
    (1.0, 1.0, 1.0),
    (2.5, -2.0, -5.0),
    (2.5, 3.0, 7.5),
    (10.0, 0.1, 1.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.multiply_by(fp2).to_f32(), *quo);
}
Source

pub const fn divide_by(self, denominator: Self, precision: u32) -> Self

Divide VaxFloatingPoint number by another.

The precision parameter is the number of bits to perform the division on. Under normal circumstances, it should be 2 more than the number of mantissa digits for rounding when converted back into the original floating-point type.

§Examples
type VFP = VaxFloatingPoint<u32>;

for (a, b, div) in [
    (0.0, 1.0, 0.0),
    (1.0, 10.0, 0.1),
    (2.5, -2.0, -1.25),
    (-2.5, 0.5, -5.0),
    (-10.0, -5.0, 2.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.divide_by(fp2, u32::BITS).to_f32(), *div);
}
Source

pub const fn from_ascii(text: &str, mask: u32) -> Result<Self, &str>

Convert from a string slice to a VaxFloatingPoint<u32>. A constant version of FromStr::from_str.

§Examples
type VFP = VaxFloatingPoint<u32>;

let F32_MASK: u32 = 0x1FFFFFF << (<u32>::BITS - f32::MANTISSA_DIGITS - 1);
let TEN: VFP = VFP::from_ascii("10", F32_MASK).unwrap();
assert_eq!(TEN.to_f32(), 10.0_f32);

for (text, value) in [
    ("0", 0.0),
    ("-0", 0.0),
    ("+0.0e0", 0.0),
    ("2.5", 2.5),
    ("1e1", 10.0),
    ("-10E-1", -1.0),
    ("1,234,567", 1234567.0),
    ("1.75", 1.75),
    ("+175e-2", 1.75),
    ("123_456_789_123_456_789_123_456_789", 123456789123456789123456789.0),
    ("0.123456789123456789123456789", 0.123456789123456789123456789),
    ("1.23e37", 1.23e37),
    ("1.23e-36", 1.23e-36),
].iter() {
    assert_eq!(VFP::from_ascii(text, F32_MASK).unwrap().to_f32(), *value);
}

for err_text in [
    "e",
    "e10",
    "1-0",
    "1.2.3",
    "1e2e3",
    "102e3-",
].iter() {
    assert!(VFP::from_ascii(err_text, F32_MASK).is_err());
}

FromStr cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_str("0").unwrap();
Source

pub const fn from_u8(src: u8) -> Self

Convert from u8 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0_u8);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<u8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_u8);
Source

pub const fn from_i8(src: i8) -> Self

Convert from i8 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i8(0_i8);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i8(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<i8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_i8);
Source

pub const fn from_u16(src: u16) -> Self

Convert from u16 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u16(0_u16);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u16(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<u16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_u16);
Source

pub const fn from_i16(src: i16) -> Self

Convert from i16 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i16(0_i16);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i16(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<i16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_i16);
Source

pub const fn from_u32(src: u32) -> Self

Convert from u32 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u32(0_u32);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u32(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<u32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_u32);
Source

pub const fn from_i32(src: i32) -> Self

Convert from i32 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i32(0_i32);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i32(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<i32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_i32);
Source

pub const fn from_u64(src: u64) -> Self

Convert from u64 to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u64(0_u64);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u64(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<u64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_u64);
Source

pub const fn from_i64(src: i64) -> Self

Convert from i64 to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i64(0_i64);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i64(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<i64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_i64);
Source

pub const fn from_usize(src: usize) -> Self

Convert from usize to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_usize(0_usize);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_usize(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<usize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_usize);
Source

pub const fn from_isize(src: isize) -> Self

Convert from isize to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_isize(0_isize);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_isize(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<isize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_isize);
Source

pub const fn from_u128(src: u128) -> Self

Convert from u128 to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u128(0_u128);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u128(10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(10.0), TEN);

From<u128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_u128);
Source

pub const fn from_i128(src: i128) -> Self

Convert from i128 to a VaxFloatingPoint<u32>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i128(0_i128);
const MINUS_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_i128(-10);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_f32(-10.0), MINUS_TEN);

From<i128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_i128);
Source

pub const fn from_f32(fp: f32) -> Self

Convert from f32 to a VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_f32(0_f32);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_f32(10.0);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(0), ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(10), TEN);

From<f32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(0_f32);
Source

pub const fn to_f32(self) -> f32

Convert from a VaxFloatingPoint<u32> to a f32.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
assert_eq!(ZERO.to_f32(), 0_f32);
assert_eq!(TEN.to_f32(), 10_f32);
Source

pub const fn from_vfp_32(src: VaxFloatingPoint<u32>) -> Self

Convert from VaxFloatingPoint<u32> to VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_32(ZERO);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_32(TEN);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(ZERO);
Source

pub const fn to_vfp_32(self) -> VaxFloatingPoint<u32>

Convert to VaxFloatingPoint<u32> from VaxFloatingPoint<u32>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(10));
Source

pub const fn from_vfp_64(src: VaxFloatingPoint<u64>) -> Self

Convert from VaxFloatingPoint<u64> to VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_64(ZERO);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_64(TEN);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(ZERO);
Source

pub const fn to_vfp_64(self) -> VaxFloatingPoint<u64>

Convert to VaxFloatingPoint<u64> from VaxFloatingPoint<u32>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(10));
Source

pub const fn from_vfp_128(src: VaxFloatingPoint<u128>) -> Self

Convert from VaxFloatingPoint<u128> to VaxFloatingPoint<u32>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_128(ZERO);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_vfp_128(TEN);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u32>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from(ZERO);
Source

pub const fn to_vfp_128(self) -> VaxFloatingPoint<u128>

Convert to VaxFloatingPoint<u128> from VaxFloatingPoint<u32>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(10));
Source§

impl VaxFloatingPoint<u64>

Source

pub const FRAC_HIGH_BIT: u64 = 9_223_372_036_854_775_808u64

Mask with the most significant bit of the VaxFloatingPoint<u64> fraction value set.

Source

pub const DIGITS: u32 = 19u32

Approximate number of significant digits in base 10.

Source

pub const ZERO: Self

A VaxFloatingPoint<u64> equal to zero.

Source

pub const fn new(sign: Sign, exp: i32, frac: u64) -> Self

Create a new VaxFloatingPoint<u64> from the sign, exponent, and fraction.

It expects a normalized the fraction value.

§Examples
type VFP = VaxFloatingPoint<u64>;
assert_eq!(VFP::new(Sign::Positive, 0, 0), VFP::ZERO);
assert_eq!(VFP::new(Sign::Positive, 0, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.5));
assert_eq!(VFP::new(Sign::Positive, 1, VFP::FRAC_HIGH_BIT), VFP::from_f32(1.0));
assert_eq!(VFP::new(Sign::Positive, -2, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.125));
Source

pub const fn from_fault(fault: Fault) -> Self

Create a new VaxFloatingPoint<u64> in a fault state.

§Examples
type VFP = VaxFloatingPoint<u64>;
assert_eq!(VFP::from_fault(Fault::DivByZero).fault(), Some(Fault::DivByZero));
assert_eq!(VFP::from_fault(Fault::Reserved).fault(), Some(Fault::Reserved));
assert_eq!(VFP::from_fault(Fault::Overflow).fault(), Some(Fault::Overflow));
assert_eq!(VFP::from_fault(Fault::Underflow).fault(), Some(Fault::Underflow));
Source

pub const fn is_zero(&self) -> bool

Check to see if the value is zero.

§Examples
type VFP = VaxFloatingPoint<u64>;

for case in [
    1.0_f32,
    123.456,
    -300.0
].iter() {
    assert_eq!(VFP::from_f32(*case).is_zero(), false);
}
assert_eq!(VFP::ZERO.is_zero(), true);
Source

pub const fn negate(self) -> Self

Negate the VaxFloatingPoint value.

§Examples
type VFP = VaxFloatingPoint<u64>;

for (case, neg) in [
    (1.0, -1.0),
    (-1.0, 1.0),
    (123.456, -123.456),
    (-300.0, 300.0),
].iter() {
    assert_eq!(VFP::from_f32(*case).negate(), VFP::from_f32(*neg));
}
assert_eq!(VFP::ZERO.negate(), VFP::ZERO);
Source

pub const fn add_to(self, other: Self, sub: bool) -> Self

Add (or subtract) two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u64>;

for (a, b, add, sub) in [
    (1.0, 0.0, 1.0, 1.0),
    (0.0, 1.0, 1.0, -1.0),
    (1.0, 1.0, 2.0, 0.0),
    (2.5, 1.0, 3.5, 1.5),
    (2.5, 3.0, 5.5, -0.5),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.add_to(fp2, false).to_f32(), *add);
    assert_eq!(fp1.add_to(fp2, true).to_f32(), *sub);
}
Source

pub const fn multiply_by(self, multiplier: Self) -> Self

Multiply two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u64>;

for (a, b, quo) in [
    (1.0, 0.0, 0.0),
    (0.0, 1.0, 0.0),
    (1.0, 1.0, 1.0),
    (2.5, -2.0, -5.0),
    (2.5, 3.0, 7.5),
    (10.0, 0.1, 1.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.multiply_by(fp2).to_f32(), *quo);
}
Source

pub const fn divide_by(self, denominator: Self, precision: u32) -> Self

Divide VaxFloatingPoint number by another.

The precision parameter is the number of bits to perform the division on. Under normal circumstances, it should be 2 more than the number of mantissa digits for rounding when converted back into the original floating-point type.

§Examples
type VFP = VaxFloatingPoint<u64>;

for (a, b, div) in [
    (0.0, 1.0, 0.0),
    (1.0, 10.0, 0.1),
    (2.5, -2.0, -1.25),
    (-2.5, 0.5, -5.0),
    (-10.0, -5.0, 2.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.divide_by(fp2, u64::BITS).to_f32(), *div);
}
Source

pub const fn from_ascii(text: &str, mask: u64) -> Result<Self, &str>

Convert from a string slice to a VaxFloatingPoint<u64>. A constant version of FromStr::from_str.

§Examples
type VFP = VaxFloatingPoint<u64>;

let F32_MASK: u64 = 0x1FFFFFF << (<u64>::BITS - f32::MANTISSA_DIGITS - 1);
let TEN: VFP = VFP::from_ascii("10", F32_MASK).unwrap();
assert_eq!(TEN.to_f32(), 10.0_f32);

for (text, value) in [
    ("0", 0.0),
    ("-0", 0.0),
    ("+0.0e0", 0.0),
    ("2.5", 2.5),
    ("1e1", 10.0),
    ("-10E-1", -1.0),
    ("1,234,567", 1234567.0),
    ("1.75", 1.75),
    ("+175e-2", 1.75),
    ("123_456_789_123_456_789_123_456_789", 123456789123456789123456789.0),
    ("0.123456789123456789123456789", 0.123456789123456789123456789),
    ("1.23e37", 1.23e37),
    ("1.23e-36", 1.23e-36),
].iter() {
    assert_eq!(VFP::from_ascii(text, F32_MASK).unwrap().to_f32(), *value);
}

for err_text in [
    "e",
    "e10",
    "1-0",
    "1.2.3",
    "1e2e3",
    "102e3-",
].iter() {
    assert!(VFP::from_ascii(err_text, F32_MASK).is_err());
}

FromStr cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_str("0").unwrap();
Source

pub const fn from_u8(src: u8) -> Self

Convert from u8 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0_u8);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<u8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_u8);
Source

pub const fn from_i8(src: i8) -> Self

Convert from i8 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i8(0_i8);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i8(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<i8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_i8);
Source

pub const fn from_u16(src: u16) -> Self

Convert from u16 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u16(0_u16);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u16(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<u16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_u16);
Source

pub const fn from_i16(src: i16) -> Self

Convert from i16 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i16(0_i16);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i16(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<i16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_i16);
Source

pub const fn from_u32(src: u32) -> Self

Convert from u32 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u32(0_u32);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u32(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<u32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_u32);
Source

pub const fn from_i32(src: i32) -> Self

Convert from i32 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i32(0_i32);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i32(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<i32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_i32);
Source

pub const fn from_u64(src: u64) -> Self

Convert from u64 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u64(0_u64);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u64(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<u64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_u64);
Source

pub const fn from_i64(src: i64) -> Self

Convert from i64 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i64(0_i64);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i64(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<i64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_i64);
Source

pub const fn from_usize(src: usize) -> Self

Convert from usize to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_usize(0_usize);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_usize(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<usize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_usize);
Source

pub const fn from_isize(src: isize) -> Self

Convert from isize to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_isize(0_isize);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_isize(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<isize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_isize);
Source

pub const fn from_u128(src: u128) -> Self

Convert from u128 to a VaxFloatingPoint<u64>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u128(0_u128);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u128(10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(10.0), TEN);

From<u128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_u128);
Source

pub const fn from_i128(src: i128) -> Self

Convert from i128 to a VaxFloatingPoint<u64>.

Can be used to define constants.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i128(0_i128);
const MINUS_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_i128(-10);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_f32(-10.0), MINUS_TEN);

From<i128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_i128);
Source

pub const fn from_f32(fp: f32) -> Self

Convert from f32 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_f32(0_f32);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_f32(10.0);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(10), TEN);

From<f32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_f32);
Source

pub const fn to_f32(self) -> f32

Convert from a VaxFloatingPoint<u64> to a f32.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(ZERO.to_f32(), 0_f32);
assert_eq!(TEN.to_f32(), 10_f32);
Source

pub const fn from_f64(fp: f64) -> Self

Convert from f64 to a VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_f64(0_f64);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_f64(10.0);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(0), ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(10), TEN);

From<f64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(0_f64);
Source

pub const fn to_f64(self) -> f64

Convert from a VaxFloatingPoint<u64> to a f64.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(ZERO.to_f64(), 0_f64);
assert_eq!(TEN.to_f64(), 10_f64);
Source

pub const fn from_vfp_32(src: VaxFloatingPoint<u32>) -> Self

Convert from VaxFloatingPoint<u32> to VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_32(ZERO);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_32(TEN);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(ZERO);
Source

pub const fn to_vfp_32(self) -> VaxFloatingPoint<u32>

Convert to VaxFloatingPoint<u32> from VaxFloatingPoint<u64>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(10));
Source

pub const fn from_vfp_64(src: VaxFloatingPoint<u64>) -> Self

Convert from VaxFloatingPoint<u64> to VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_64(ZERO);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_64(TEN);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(ZERO);
Source

pub const fn to_vfp_64(self) -> VaxFloatingPoint<u64>

Convert to VaxFloatingPoint<u64> from VaxFloatingPoint<u64>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(10));
Source

pub const fn from_vfp_128(src: VaxFloatingPoint<u128>) -> Self

Convert from VaxFloatingPoint<u128> to VaxFloatingPoint<u64>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_128(ZERO);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_vfp_128(TEN);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u64>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from(ZERO);
Source

pub const fn to_vfp_128(self) -> VaxFloatingPoint<u128>

Convert to VaxFloatingPoint<u128> from VaxFloatingPoint<u64>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(10));
Source§

impl VaxFloatingPoint<u128>

Source

pub const FRAC_HIGH_BIT: u128 = 170_141_183_460_469_231_731_687_303_715_884_105_728u128

Mask with the most significant bit of the VaxFloatingPoint<u128> fraction value set.

Source

pub const DIGITS: u32 = 38u32

Approximate number of significant digits in base 10.

Source

pub const ZERO: Self

A VaxFloatingPoint<u128> equal to zero.

Source

pub const fn new(sign: Sign, exp: i32, frac: u128) -> Self

Create a new VaxFloatingPoint<u128> from the sign, exponent, and fraction.

It expects a normalized the fraction value.

§Examples
type VFP = VaxFloatingPoint<u128>;
assert_eq!(VFP::new(Sign::Positive, 0, 0), VFP::ZERO);
assert_eq!(VFP::new(Sign::Positive, 0, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.5));
assert_eq!(VFP::new(Sign::Positive, 1, VFP::FRAC_HIGH_BIT), VFP::from_f32(1.0));
assert_eq!(VFP::new(Sign::Positive, -2, VFP::FRAC_HIGH_BIT), VFP::from_f32(0.125));
Source

pub const fn from_fault(fault: Fault) -> Self

Create a new VaxFloatingPoint<u128> in a fault state.

§Examples
type VFP = VaxFloatingPoint<u128>;
assert_eq!(VFP::from_fault(Fault::DivByZero).fault(), Some(Fault::DivByZero));
assert_eq!(VFP::from_fault(Fault::Reserved).fault(), Some(Fault::Reserved));
assert_eq!(VFP::from_fault(Fault::Overflow).fault(), Some(Fault::Overflow));
assert_eq!(VFP::from_fault(Fault::Underflow).fault(), Some(Fault::Underflow));
Source

pub const fn is_zero(&self) -> bool

Check to see if the value is zero.

§Examples
type VFP = VaxFloatingPoint<u128>;

for case in [
    1.0_f32,
    123.456,
    -300.0
].iter() {
    assert_eq!(VFP::from_f32(*case).is_zero(), false);
}
assert_eq!(VFP::ZERO.is_zero(), true);
Source

pub const fn negate(self) -> Self

Negate the VaxFloatingPoint value.

§Examples
type VFP = VaxFloatingPoint<u128>;

for (case, neg) in [
    (1.0, -1.0),
    (-1.0, 1.0),
    (123.456, -123.456),
    (-300.0, 300.0),
].iter() {
    assert_eq!(VFP::from_f32(*case).negate(), VFP::from_f32(*neg));
}
assert_eq!(VFP::ZERO.negate(), VFP::ZERO);
Source

pub const fn add_to(self, other: Self, sub: bool) -> Self

Add (or subtract) two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u128>;

for (a, b, add, sub) in [
    (1.0, 0.0, 1.0, 1.0),
    (0.0, 1.0, 1.0, -1.0),
    (1.0, 1.0, 2.0, 0.0),
    (2.5, 1.0, 3.5, 1.5),
    (2.5, 3.0, 5.5, -0.5),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.add_to(fp2, false).to_f32(), *add);
    assert_eq!(fp1.add_to(fp2, true).to_f32(), *sub);
}
Source

pub const fn multiply_by(self, multiplier: Self) -> Self

Multiply two VaxFloatingPoint numbers.

§Examples
type VFP = VaxFloatingPoint<u128>;

for (a, b, quo) in [
    (1.0, 0.0, 0.0),
    (0.0, 1.0, 0.0),
    (1.0, 1.0, 1.0),
    (2.5, -2.0, -5.0),
    (2.5, 3.0, 7.5),
    (10.0, 0.1, 1.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.multiply_by(fp2).to_f32(), *quo);
}
Source

pub const fn divide_by(self, denominator: Self, precision: u32) -> Self

Divide VaxFloatingPoint number by another.

The precision parameter is the number of bits to perform the division on. Under normal circumstances, it should be 2 more than the number of mantissa digits for rounding when converted back into the original floating-point type.

§Examples
type VFP = VaxFloatingPoint<u128>;

for (a, b, div) in [
    (0.0, 1.0, 0.0),
    (1.0, 10.0, 0.1),
    (2.5, -2.0, -1.25),
    (-2.5, 0.5, -5.0),
    (-10.0, -5.0, 2.0),
].iter() {
    let fp1 = VFP::from_f32(*a);
    let fp2 = VFP::from_f32(*b);
    assert_eq!(fp1.divide_by(fp2, u128::BITS).to_f32(), *div);
}
Source

pub const fn from_ascii(text: &str, mask: u128) -> Result<Self, &str>

Convert from a string slice to a VaxFloatingPoint<u128>. A constant version of FromStr::from_str.

§Examples
type VFP = VaxFloatingPoint<u128>;

let F32_MASK: u128 = 0x1FFFFFF << (<u128>::BITS - f32::MANTISSA_DIGITS - 1);
let TEN: VFP = VFP::from_ascii("10", F32_MASK).unwrap();
assert_eq!(TEN.to_f32(), 10.0_f32);

for (text, value) in [
    ("0", 0.0),
    ("-0", 0.0),
    ("+0.0e0", 0.0),
    ("2.5", 2.5),
    ("1e1", 10.0),
    ("-10E-1", -1.0),
    ("1,234,567", 1234567.0),
    ("1.75", 1.75),
    ("+175e-2", 1.75),
    ("123_456_789_123_456_789_123_456_789", 123456789123456789123456789.0),
    ("0.123456789123456789123456789", 0.123456789123456789123456789),
    ("1.23e37", 1.23e37),
    ("1.23e-36", 1.23e-36),
].iter() {
    assert_eq!(VFP::from_ascii(text, F32_MASK).unwrap().to_f32(), *value);
}

for err_text in [
    "e",
    "e10",
    "1-0",
    "1.2.3",
    "1e2e3",
    "102e3-",
].iter() {
    assert!(VFP::from_ascii(err_text, F32_MASK).is_err());
}

FromStr cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_str("0").unwrap();
Source

pub const fn from_u8(src: u8) -> Self

Convert from u8 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0_u8);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<u8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_u8);
Source

pub const fn from_i8(src: i8) -> Self

Convert from i8 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i8(0_i8);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i8(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<i8> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_i8);
Source

pub const fn from_u16(src: u16) -> Self

Convert from u16 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u16(0_u16);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u16(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<u16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_u16);
Source

pub const fn from_i16(src: i16) -> Self

Convert from i16 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i16(0_i16);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i16(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<i16> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_i16);
Source

pub const fn from_u32(src: u32) -> Self

Convert from u32 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u32(0_u32);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u32(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<u32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_u32);
Source

pub const fn from_i32(src: i32) -> Self

Convert from i32 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i32(0_i32);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i32(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<i32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_i32);
Source

pub const fn from_u64(src: u64) -> Self

Convert from u64 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u64(0_u64);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u64(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<u64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_u64);
Source

pub const fn from_i64(src: i64) -> Self

Convert from i64 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i64(0_i64);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i64(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<i64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_i64);
Source

pub const fn from_usize(src: usize) -> Self

Convert from usize to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_usize(0_usize);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_usize(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<usize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_usize);
Source

pub const fn from_isize(src: isize) -> Self

Convert from isize to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_isize(0_isize);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_isize(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<isize> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_isize);
Source

pub const fn from_u128(src: u128) -> Self

Convert from u128 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u128(0_u128);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u128(10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(10.0), TEN);

From<u128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_u128);
Source

pub const fn from_i128(src: i128) -> Self

Convert from i128 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i128(0_i128);
const MINUS_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_i128(-10);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(0.0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_f32(-10.0), MINUS_TEN);

From<i128> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_i128);
Source

pub const fn from_f32(fp: f32) -> Self

Convert from f32 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_f32(0_f32);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_f32(10.0);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(10), TEN);

From<f32> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_f32);
Source

pub const fn to_f32(self) -> f32

Convert from a VaxFloatingPoint<u128> to a f32.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(ZERO.to_f32(), 0_f32);
assert_eq!(TEN.to_f32(), 10_f32);
Source

pub const fn from_f64(fp: f64) -> Self

Convert from f64 to a VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_f64(0_f64);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_f64(10.0);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(0), ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(10), TEN);

From<f64> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(0_f64);
Source

pub const fn to_f64(self) -> f64

Convert from a VaxFloatingPoint<u128> to a f64.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(ZERO.to_f64(), 0_f64);
assert_eq!(TEN.to_f64(), 10_f64);
Source

pub const fn from_vfp_32(src: VaxFloatingPoint<u32>) -> Self

Convert from VaxFloatingPoint<u32> to VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const TEN: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_32(ZERO);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_32(TEN);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u32> = VaxFloatingPoint::<u32>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(ZERO);
Source

pub const fn to_vfp_32(self) -> VaxFloatingPoint<u32>

Convert to VaxFloatingPoint<u32> from VaxFloatingPoint<u128>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_32(), VaxFloatingPoint::<u32>::from_u8(10));
Source

pub const fn from_vfp_64(src: VaxFloatingPoint<u64>) -> Self

Convert from VaxFloatingPoint<u64> to VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const TEN: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_64(ZERO);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_64(TEN);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u64> = VaxFloatingPoint::<u64>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(ZERO);
Source

pub const fn to_vfp_64(self) -> VaxFloatingPoint<u64>

Convert to VaxFloatingPoint<u64> from VaxFloatingPoint<u128>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_64(), VaxFloatingPoint::<u64>::from_u8(10));
Source

pub const fn from_vfp_128(src: VaxFloatingPoint<u128>) -> Self

Convert from VaxFloatingPoint<u128> to VaxFloatingPoint<u128>.

Can be used to define constants.

§Examples
const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_128(ZERO);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_vfp_128(TEN);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(0), FROM_ZERO);
assert_eq!(VaxFloatingPoint::<u128>::from_u8(10), FROM_TEN);

From<VaxFloatingPoint::<$fx>> cannot be used to define constants.

const ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from(ZERO);
Source

pub const fn to_vfp_128(self) -> VaxFloatingPoint<u128>

Convert to VaxFloatingPoint<u128> from VaxFloatingPoint<u128>.

§Examples
const FROM_ZERO: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(0);
const FROM_TEN: VaxFloatingPoint<u128> = VaxFloatingPoint::<u128>::from_u8(10);
assert_eq!(FROM_ZERO.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(0));
assert_eq!(FROM_TEN.to_vfp_128(), VaxFloatingPoint::<u128>::from_u8(10));

Trait Implementations§

Source§

impl Add<&VaxFloatingPoint<u128>> for &VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Add<VaxFloatingPoint<u128>>>::Output

Performs the + operation. Read more
Source§

impl Add<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Add<VaxFloatingPoint<u128>>>::Output

Performs the + operation. Read more
Source§

impl Add<&VaxFloatingPoint<u32>> for &VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Add<VaxFloatingPoint<u32>>>::Output

Performs the + operation. Read more
Source§

impl Add<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Add<VaxFloatingPoint<u32>>>::Output

Performs the + operation. Read more
Source§

impl Add<&VaxFloatingPoint<u64>> for &VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Add<VaxFloatingPoint<u64>>>::Output

Performs the + operation. Read more
Source§

impl Add<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Add<VaxFloatingPoint<u64>>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<VaxFloatingPoint<u128>> for &'a VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Add<VaxFloatingPoint<u128>>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<VaxFloatingPoint<u32>> for &'a VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Add<VaxFloatingPoint<u32>>>::Output

Performs the + operation. Read more
Source§

impl<'a> Add<VaxFloatingPoint<u64>> for &'a VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add( self, other: VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Add<VaxFloatingPoint<u64>>>::Output

Performs the + operation. Read more
Source§

impl Add for VaxFloatingPoint<u128>

Source§

type Output = VaxFloatingPoint<u128>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for VaxFloatingPoint<u32>

Source§

type Output = VaxFloatingPoint<u32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for VaxFloatingPoint<u64>

Source§

type Output = VaxFloatingPoint<u64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

fn add_assign(&mut self, other: &VaxFloatingPoint<u128>)

Performs the += operation. Read more
Source§

impl AddAssign<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

fn add_assign(&mut self, other: &VaxFloatingPoint<u32>)

Performs the += operation. Read more
Source§

impl AddAssign<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

fn add_assign(&mut self, other: &VaxFloatingPoint<u64>)

Performs the += operation. Read more
Source§

impl AddAssign for VaxFloatingPoint<u128>

Source§

fn add_assign(&mut self, other: VaxFloatingPoint<u128>)

Performs the += operation. Read more
Source§

impl AddAssign for VaxFloatingPoint<u32>

Source§

fn add_assign(&mut self, other: VaxFloatingPoint<u32>)

Performs the += operation. Read more
Source§

impl AddAssign for VaxFloatingPoint<u64>

Source§

fn add_assign(&mut self, other: VaxFloatingPoint<u64>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for VaxFloatingPoint<T>

Source§

fn clone(&self) -> VaxFloatingPoint<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: UpperHex> Debug for VaxFloatingPoint<T>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for VaxFloatingPoint<T>

Source§

fn default() -> VaxFloatingPoint<T>

Returns the “default value” for a type. Read more
Source§

impl Display for VaxFloatingPoint<u128>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for VaxFloatingPoint<u32>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for VaxFloatingPoint<u64>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div<&VaxFloatingPoint<u128>> for &VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Div<VaxFloatingPoint<u128>>>::Output

Performs the / operation. Read more
Source§

impl Div<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Div<VaxFloatingPoint<u128>>>::Output

Performs the / operation. Read more
Source§

impl Div<&VaxFloatingPoint<u32>> for &VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Div<VaxFloatingPoint<u32>>>::Output

Performs the / operation. Read more
Source§

impl Div<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Div<VaxFloatingPoint<u32>>>::Output

Performs the / operation. Read more
Source§

impl Div<&VaxFloatingPoint<u64>> for &VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Div<VaxFloatingPoint<u64>>>::Output

Performs the / operation. Read more
Source§

impl Div<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Div<VaxFloatingPoint<u64>>>::Output

Performs the / operation. Read more
Source§

impl<'a> Div<VaxFloatingPoint<u128>> for &'a VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Div<VaxFloatingPoint<u128>>>::Output

Performs the / operation. Read more
Source§

impl<'a> Div<VaxFloatingPoint<u32>> for &'a VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Div<VaxFloatingPoint<u32>>>::Output

Performs the / operation. Read more
Source§

impl<'a> Div<VaxFloatingPoint<u64>> for &'a VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Div>::Output

The resulting type after applying the / operator.
Source§

fn div( self, other: VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Div<VaxFloatingPoint<u64>>>::Output

Performs the / operation. Read more
Source§

impl Div for VaxFloatingPoint<u128>

Source§

type Output = VaxFloatingPoint<u128>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for VaxFloatingPoint<u32>

Source§

type Output = VaxFloatingPoint<u32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for VaxFloatingPoint<u64>

Source§

type Output = VaxFloatingPoint<u64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

fn div_assign(&mut self, other: &VaxFloatingPoint<u128>)

Performs the /= operation. Read more
Source§

impl DivAssign<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

fn div_assign(&mut self, other: &VaxFloatingPoint<u32>)

Performs the /= operation. Read more
Source§

impl DivAssign<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

fn div_assign(&mut self, other: &VaxFloatingPoint<u64>)

Performs the /= operation. Read more
Source§

impl DivAssign for VaxFloatingPoint<u128>

Source§

fn div_assign(&mut self, other: VaxFloatingPoint<u128>)

Performs the /= operation. Read more
Source§

impl DivAssign for VaxFloatingPoint<u32>

Source§

fn div_assign(&mut self, other: VaxFloatingPoint<u32>)

Performs the /= operation. Read more
Source§

impl DivAssign for VaxFloatingPoint<u64>

Source§

fn div_assign(&mut self, other: VaxFloatingPoint<u64>)

Performs the /= operation. Read more
Source§

impl From<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u32>

Source§

fn from(vfp: &VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u64>

Source§

fn from(vfp: &VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u128>> for f32

Source§

fn from(vfp: &VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u128>> for f64

Source§

fn from(vfp: &VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u128>

Source§

fn from(vfp: &VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u64>

Source§

fn from(vfp: &VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u32>> for f32

Source§

fn from(vfp: &VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u128>

Source§

fn from(vfp: &VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u32>

Source§

fn from(vfp: &VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u64>> for f32

Source§

fn from(vfp: &VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<&VaxFloatingPoint<u64>> for f64

Source§

fn from(vfp: &VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<&f32> for VaxFloatingPoint<u128>

Source§

fn from(fp: &f32) -> Self

Converts to this type from the input type.
Source§

impl From<&f32> for VaxFloatingPoint<u32>

Source§

fn from(fp: &f32) -> Self

Converts to this type from the input type.
Source§

impl From<&f32> for VaxFloatingPoint<u64>

Source§

fn from(fp: &f32) -> Self

Converts to this type from the input type.
Source§

impl From<&f64> for VaxFloatingPoint<u128>

Source§

fn from(fp: &f64) -> Self

Converts to this type from the input type.
Source§

impl From<&f64> for VaxFloatingPoint<u64>

Source§

fn from(fp: &f64) -> Self

Converts to this type from the input type.
Source§

impl From<&i128> for VaxFloatingPoint<u128>

Source§

fn from(src: &i128) -> Self

Converts to this type from the input type.

Source§

impl From<&i128> for VaxFloatingPoint<u32>

Source§

fn from(src: &i128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&i128> for VaxFloatingPoint<u64>

Source§

fn from(src: &i128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&i16> for VaxFloatingPoint<u128>

Source§

fn from(src: &i16) -> Self

Converts to this type from the input type.

Source§

impl From<&i16> for VaxFloatingPoint<u32>

Source§

fn from(src: &i16) -> Self

Converts to this type from the input type.

Source§

impl From<&i16> for VaxFloatingPoint<u64>

Source§

fn from(src: &i16) -> Self

Converts to this type from the input type.

Source§

impl From<&i32> for VaxFloatingPoint<u128>

Source§

fn from(src: &i32) -> Self

Converts to this type from the input type.

Source§

impl From<&i32> for VaxFloatingPoint<u32>

Source§

fn from(src: &i32) -> Self

Converts to this type from the input type.

Source§

impl From<&i32> for VaxFloatingPoint<u64>

Source§

fn from(src: &i32) -> Self

Converts to this type from the input type.

Source§

impl From<&i64> for VaxFloatingPoint<u128>

Source§

fn from(src: &i64) -> Self

Converts to this type from the input type.

Source§

impl From<&i64> for VaxFloatingPoint<u32>

Source§

fn from(src: &i64) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&i64> for VaxFloatingPoint<u64>

Source§

fn from(src: &i64) -> Self

Converts to this type from the input type.

Source§

impl From<&i8> for VaxFloatingPoint<u128>

Source§

fn from(src: &i8) -> Self

Converts to this type from the input type.

Source§

impl From<&i8> for VaxFloatingPoint<u32>

Source§

fn from(src: &i8) -> Self

Converts to this type from the input type.

Source§

impl From<&i8> for VaxFloatingPoint<u64>

Source§

fn from(src: &i8) -> Self

Converts to this type from the input type.

Source§

impl From<&isize> for VaxFloatingPoint<u128>

Source§

fn from(src: &isize) -> Self

Converts to this type from the input type.

Source§

impl From<&isize> for VaxFloatingPoint<u32>

Source§

fn from(src: &isize) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&isize> for VaxFloatingPoint<u64>

Source§

fn from(src: &isize) -> Self

Converts to this type from the input type.

Source§

impl From<&u128> for VaxFloatingPoint<u128>

Source§

fn from(src: &u128) -> Self

Converts to this type from the input type.

Source§

impl From<&u128> for VaxFloatingPoint<u32>

Source§

fn from(src: &u128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&u128> for VaxFloatingPoint<u64>

Source§

fn from(src: &u128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&u16> for VaxFloatingPoint<u128>

Source§

fn from(src: &u16) -> Self

Converts to this type from the input type.

Source§

impl From<&u16> for VaxFloatingPoint<u32>

Source§

fn from(src: &u16) -> Self

Converts to this type from the input type.

Source§

impl From<&u16> for VaxFloatingPoint<u64>

Source§

fn from(src: &u16) -> Self

Converts to this type from the input type.

Source§

impl From<&u32> for VaxFloatingPoint<u128>

Source§

fn from(src: &u32) -> Self

Converts to this type from the input type.

Source§

impl From<&u32> for VaxFloatingPoint<u32>

Source§

fn from(src: &u32) -> Self

Converts to this type from the input type.

Source§

impl From<&u32> for VaxFloatingPoint<u64>

Source§

fn from(src: &u32) -> Self

Converts to this type from the input type.

Source§

impl From<&u64> for VaxFloatingPoint<u128>

Source§

fn from(src: &u64) -> Self

Converts to this type from the input type.

Source§

impl From<&u64> for VaxFloatingPoint<u32>

Source§

fn from(src: &u64) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&u64> for VaxFloatingPoint<u64>

Source§

fn from(src: &u64) -> Self

Converts to this type from the input type.

Source§

impl From<&u8> for VaxFloatingPoint<u128>

Source§

fn from(src: &u8) -> Self

Converts to this type from the input type.

Source§

impl From<&u8> for VaxFloatingPoint<u32>

Source§

fn from(src: &u8) -> Self

Converts to this type from the input type.

Source§

impl From<&u8> for VaxFloatingPoint<u64>

Source§

fn from(src: &u8) -> Self

Converts to this type from the input type.

Source§

impl From<&usize> for VaxFloatingPoint<u128>

Source§

fn from(src: &usize) -> Self

Converts to this type from the input type.

Source§

impl From<&usize> for VaxFloatingPoint<u32>

Source§

fn from(src: &usize) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<&usize> for VaxFloatingPoint<u64>

Source§

fn from(src: &usize) -> Self

Converts to this type from the input type.

Source§

impl From<VaxFloatingPoint<u128>> for VaxFloatingPoint<u32>

Source§

fn from(vfp: VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u128>> for VaxFloatingPoint<u64>

Source§

fn from(vfp: VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u128>> for f32

Source§

fn from(vfp: VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u128>> for f64

Source§

fn from(vfp: VaxFloatingPoint<u128>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u32>> for VaxFloatingPoint<u128>

Source§

fn from(vfp: VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u32>> for VaxFloatingPoint<u64>

Source§

fn from(vfp: VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u32>> for f32

Source§

fn from(vfp: VaxFloatingPoint<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u64>> for VaxFloatingPoint<u128>

Source§

fn from(vfp: VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u64>> for VaxFloatingPoint<u32>

Source§

fn from(vfp: VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u64>> for f32

Source§

fn from(vfp: VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<VaxFloatingPoint<u64>> for f64

Source§

fn from(vfp: VaxFloatingPoint<u64>) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for VaxFloatingPoint<u128>

Source§

fn from(fp: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for VaxFloatingPoint<u32>

Source§

fn from(fp: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for VaxFloatingPoint<u64>

Source§

fn from(fp: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for VaxFloatingPoint<u128>

Source§

fn from(fp: f64) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for VaxFloatingPoint<u64>

Source§

fn from(fp: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for VaxFloatingPoint<u128>

Source§

fn from(src: i128) -> Self

Converts to this type from the input type.

Source§

impl From<i128> for VaxFloatingPoint<u32>

Source§

fn from(src: i128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<i128> for VaxFloatingPoint<u64>

Source§

fn from(src: i128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<i16> for VaxFloatingPoint<u128>

Source§

fn from(src: i16) -> Self

Converts to this type from the input type.

Source§

impl From<i16> for VaxFloatingPoint<u32>

Source§

fn from(src: i16) -> Self

Converts to this type from the input type.

Source§

impl From<i16> for VaxFloatingPoint<u64>

Source§

fn from(src: i16) -> Self

Converts to this type from the input type.

Source§

impl From<i32> for VaxFloatingPoint<u128>

Source§

fn from(src: i32) -> Self

Converts to this type from the input type.

Source§

impl From<i32> for VaxFloatingPoint<u32>

Source§

fn from(src: i32) -> Self

Converts to this type from the input type.

Source§

impl From<i32> for VaxFloatingPoint<u64>

Source§

fn from(src: i32) -> Self

Converts to this type from the input type.

Source§

impl From<i64> for VaxFloatingPoint<u128>

Source§

fn from(src: i64) -> Self

Converts to this type from the input type.

Source§

impl From<i64> for VaxFloatingPoint<u32>

Source§

fn from(src: i64) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<i64> for VaxFloatingPoint<u64>

Source§

fn from(src: i64) -> Self

Converts to this type from the input type.

Source§

impl From<i8> for VaxFloatingPoint<u128>

Source§

fn from(src: i8) -> Self

Converts to this type from the input type.

Source§

impl From<i8> for VaxFloatingPoint<u32>

Source§

fn from(src: i8) -> Self

Converts to this type from the input type.

Source§

impl From<i8> for VaxFloatingPoint<u64>

Source§

fn from(src: i8) -> Self

Converts to this type from the input type.

Source§

impl From<isize> for VaxFloatingPoint<u128>

Source§

fn from(src: isize) -> Self

Converts to this type from the input type.

Source§

impl From<isize> for VaxFloatingPoint<u32>

Source§

fn from(src: isize) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<isize> for VaxFloatingPoint<u64>

Source§

fn from(src: isize) -> Self

Converts to this type from the input type.

Source§

impl From<u128> for VaxFloatingPoint<u128>

Source§

fn from(src: u128) -> Self

Converts to this type from the input type.

Source§

impl From<u128> for VaxFloatingPoint<u32>

Source§

fn from(src: u128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<u128> for VaxFloatingPoint<u64>

Source§

fn from(src: u128) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u64::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<u16> for VaxFloatingPoint<u128>

Source§

fn from(src: u16) -> Self

Converts to this type from the input type.

Source§

impl From<u16> for VaxFloatingPoint<u32>

Source§

fn from(src: u16) -> Self

Converts to this type from the input type.

Source§

impl From<u16> for VaxFloatingPoint<u64>

Source§

fn from(src: u16) -> Self

Converts to this type from the input type.

Source§

impl From<u32> for VaxFloatingPoint<u128>

Source§

fn from(src: u32) -> Self

Converts to this type from the input type.

Source§

impl From<u32> for VaxFloatingPoint<u32>

Source§

fn from(src: u32) -> Self

Converts to this type from the input type.

Source§

impl From<u32> for VaxFloatingPoint<u64>

Source§

fn from(src: u32) -> Self

Converts to this type from the input type.

Source§

impl From<u64> for VaxFloatingPoint<u128>

Source§

fn from(src: u64) -> Self

Converts to this type from the input type.

Source§

impl From<u64> for VaxFloatingPoint<u32>

Source§

fn from(src: u64) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<u64> for VaxFloatingPoint<u64>

Source§

fn from(src: u64) -> Self

Converts to this type from the input type.

Source§

impl From<u8> for VaxFloatingPoint<u128>

Source§

fn from(src: u8) -> Self

Converts to this type from the input type.

Source§

impl From<u8> for VaxFloatingPoint<u32>

Source§

fn from(src: u8) -> Self

Converts to this type from the input type.

Source§

impl From<u8> for VaxFloatingPoint<u64>

Source§

fn from(src: u8) -> Self

Converts to this type from the input type.

Source§

impl From<usize> for VaxFloatingPoint<u128>

Source§

fn from(src: usize) -> Self

Converts to this type from the input type.

Source§

impl From<usize> for VaxFloatingPoint<u32>

Source§

fn from(src: usize) -> Self

Converts to this type from the input type.

Note: Only the most significant set bits that fit into the number of u32::BITS will be preserved. This will result in a loss of precision.

Source§

impl From<usize> for VaxFloatingPoint<u64>

Source§

fn from(src: usize) -> Self

Converts to this type from the input type.

Source§

impl FromStr for VaxFloatingPoint<u128>

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for VaxFloatingPoint<u32>

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for VaxFloatingPoint<u64>

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl LowerExp for VaxFloatingPoint<u128>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LowerExp for VaxFloatingPoint<u32>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl LowerExp for VaxFloatingPoint<u64>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Mul<&VaxFloatingPoint<u128>> for &VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Mul<VaxFloatingPoint<u128>>>::Output

Performs the * operation. Read more
Source§

impl Mul<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Mul<VaxFloatingPoint<u128>>>::Output

Performs the * operation. Read more
Source§

impl Mul<&VaxFloatingPoint<u32>> for &VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Mul<VaxFloatingPoint<u32>>>::Output

Performs the * operation. Read more
Source§

impl Mul<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Mul<VaxFloatingPoint<u32>>>::Output

Performs the * operation. Read more
Source§

impl Mul<&VaxFloatingPoint<u64>> for &VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Mul<VaxFloatingPoint<u64>>>::Output

Performs the * operation. Read more
Source§

impl Mul<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Mul<VaxFloatingPoint<u64>>>::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<VaxFloatingPoint<u128>> for &'a VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Mul<VaxFloatingPoint<u128>>>::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<VaxFloatingPoint<u32>> for &'a VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Mul<VaxFloatingPoint<u32>>>::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<VaxFloatingPoint<u64>> for &'a VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Mul>::Output

The resulting type after applying the * operator.
Source§

fn mul( self, other: VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Mul<VaxFloatingPoint<u64>>>::Output

Performs the * operation. Read more
Source§

impl Mul for VaxFloatingPoint<u128>

Source§

type Output = VaxFloatingPoint<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for VaxFloatingPoint<u32>

Source§

type Output = VaxFloatingPoint<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for VaxFloatingPoint<u64>

Source§

type Output = VaxFloatingPoint<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

fn mul_assign(&mut self, other: &VaxFloatingPoint<u128>)

Performs the *= operation. Read more
Source§

impl MulAssign<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

fn mul_assign(&mut self, other: &VaxFloatingPoint<u32>)

Performs the *= operation. Read more
Source§

impl MulAssign<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

fn mul_assign(&mut self, other: &VaxFloatingPoint<u64>)

Performs the *= operation. Read more
Source§

impl MulAssign for VaxFloatingPoint<u128>

Source§

fn mul_assign(&mut self, other: VaxFloatingPoint<u128>)

Performs the *= operation. Read more
Source§

impl MulAssign for VaxFloatingPoint<u32>

Source§

fn mul_assign(&mut self, other: VaxFloatingPoint<u32>)

Performs the *= operation. Read more
Source§

impl MulAssign for VaxFloatingPoint<u64>

Source§

fn mul_assign(&mut self, other: VaxFloatingPoint<u64>)

Performs the *= operation. Read more
Source§

impl<T: PartialEq> PartialEq for VaxFloatingPoint<T>

Source§

fn eq(&self, other: &VaxFloatingPoint<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for VaxFloatingPoint<u128>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for VaxFloatingPoint<u32>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for VaxFloatingPoint<u64>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<&VaxFloatingPoint<u128>> for &VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Sub<VaxFloatingPoint<u128>>>::Output

Performs the - operation. Read more
Source§

impl Sub<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Sub<VaxFloatingPoint<u128>>>::Output

Performs the - operation. Read more
Source§

impl Sub<&VaxFloatingPoint<u32>> for &VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Sub<VaxFloatingPoint<u32>>>::Output

Performs the - operation. Read more
Source§

impl Sub<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Sub<VaxFloatingPoint<u32>>>::Output

Performs the - operation. Read more
Source§

impl Sub<&VaxFloatingPoint<u64>> for &VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Sub<VaxFloatingPoint<u64>>>::Output

Performs the - operation. Read more
Source§

impl Sub<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: &VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Sub<VaxFloatingPoint<u64>>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<VaxFloatingPoint<u128>> for &'a VaxFloatingPoint<u128>

Source§

type Output = <VaxFloatingPoint<u128> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: VaxFloatingPoint<u128>, ) -> <VaxFloatingPoint<u128> as Sub<VaxFloatingPoint<u128>>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<VaxFloatingPoint<u32>> for &'a VaxFloatingPoint<u32>

Source§

type Output = <VaxFloatingPoint<u32> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: VaxFloatingPoint<u32>, ) -> <VaxFloatingPoint<u32> as Sub<VaxFloatingPoint<u32>>>::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<VaxFloatingPoint<u64>> for &'a VaxFloatingPoint<u64>

Source§

type Output = <VaxFloatingPoint<u64> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub( self, other: VaxFloatingPoint<u64>, ) -> <VaxFloatingPoint<u64> as Sub<VaxFloatingPoint<u64>>>::Output

Performs the - operation. Read more
Source§

impl Sub for VaxFloatingPoint<u128>

Source§

type Output = VaxFloatingPoint<u128>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for VaxFloatingPoint<u32>

Source§

type Output = VaxFloatingPoint<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for VaxFloatingPoint<u64>

Source§

type Output = VaxFloatingPoint<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<&VaxFloatingPoint<u128>> for VaxFloatingPoint<u128>

Source§

fn sub_assign(&mut self, other: &VaxFloatingPoint<u128>)

Performs the -= operation. Read more
Source§

impl SubAssign<&VaxFloatingPoint<u32>> for VaxFloatingPoint<u32>

Source§

fn sub_assign(&mut self, other: &VaxFloatingPoint<u32>)

Performs the -= operation. Read more
Source§

impl SubAssign<&VaxFloatingPoint<u64>> for VaxFloatingPoint<u64>

Source§

fn sub_assign(&mut self, other: &VaxFloatingPoint<u64>)

Performs the -= operation. Read more
Source§

impl SubAssign for VaxFloatingPoint<u128>

Source§

fn sub_assign(&mut self, other: VaxFloatingPoint<u128>)

Performs the -= operation. Read more
Source§

impl SubAssign for VaxFloatingPoint<u32>

Source§

fn sub_assign(&mut self, other: VaxFloatingPoint<u32>)

Performs the -= operation. Read more
Source§

impl SubAssign for VaxFloatingPoint<u64>

Source§

fn sub_assign(&mut self, other: VaxFloatingPoint<u64>)

Performs the -= operation. Read more
Source§

impl UpperExp for VaxFloatingPoint<u128>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl UpperExp for VaxFloatingPoint<u32>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl UpperExp for VaxFloatingPoint<u64>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Copy> Copy for VaxFloatingPoint<T>

Source§

impl<T: Eq> Eq for VaxFloatingPoint<T>

Source§

impl<T> StructuralPartialEq for VaxFloatingPoint<T>

Auto Trait Implementations§

§

impl<T> Freeze for VaxFloatingPoint<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for VaxFloatingPoint<T>
where T: RefUnwindSafe,

§

impl<T> Send for VaxFloatingPoint<T>
where T: Send,

§

impl<T> Sync for VaxFloatingPoint<T>
where T: Sync,

§

impl<T> Unpin for VaxFloatingPoint<T>
where T: Unpin,

§

impl<T> UnwindSafe for VaxFloatingPoint<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.