Skip to main content

Bcd

Struct Bcd 

Source
pub struct Bcd<const BYTES: usize>(/* private fields */);
Expand description

A packed Binary-Coded Decimal (BCD) value backed by BYTES bytes.

Each byte encodes two decimal digits: the high nibble holds the more-significant digit and the low nibble holds the less-significant digit. For example, the decimal value 42 is stored as 0x42.

§Zero-byte Bcd<0>

Bcd<0> is a valid, zero-sized type that stores no digits. try_into_* always yields 0, and try_from_* accepts only 0 (any other value overflows). It exists so the const-generic bound stays uniform; in most use cases BYTES >= 1 is expected.

§Examples

use const_bcd::Bcd;

let a: Bcd<2> = Bcd::try_from_u16(100).unwrap();
let b: Bcd<2> = Bcd::try_from_u16(200).unwrap();
assert!(a < b);

Implementations§

Source§

impl<const BYTES: usize> Bcd<BYTES>

Source

pub const fn from_bcd_bytes(bytes: [u8; BYTES]) -> Result<Self, InvalidBcdDigit>

Constructs a Bcd from a raw byte array already in packed BCD format.

Each nibble in bytes must be a valid decimal digit (0..=9). If any nibble is in the range 10..=15, an InvalidBcdDigit error is returned containing the offending nibble value.

§Errors

Returns Err(InvalidBcdDigit) if any nibble exceeds 9.

§Examples
use const_bcd::Bcd;

// Valid BCD bytes
let n = Bcd::<2>::from_bcd_bytes([0x12, 0x34]).unwrap();
assert_eq!(n.to_string(), "1234");

// Invalid: high nibble of first byte is 0xA
assert!(Bcd::<2>::from_bcd_bytes([0xA0, 0x00]).is_err());

// Invalid: low nibble of second byte is 0xF
assert!(Bcd::<2>::from_bcd_bytes([0x00, 0x0F]).is_err());
Source

pub const fn try_from_u8(value: u8) -> Result<Self, BcdOverflowError>

Converts a u8 to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<1>::try_from_u8(99).unwrap();
assert_eq!(n.to_string(), "99");

// 100 requires 3 digits but Bcd<1> holds at most 2
assert!(Bcd::<1>::try_from_u8(100).is_err());
Source

pub const fn try_from_u16(value: u16) -> Result<Self, BcdOverflowError>

Converts a u16 to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<2>::try_from_u16(9999).unwrap();
assert_eq!(n.to_string(), "9999");

// Bcd<1> can hold at most 99
assert!(Bcd::<1>::try_from_u16(100).is_err());
Source

pub const fn try_from_u32(value: u32) -> Result<Self, BcdOverflowError>

Converts a u32 to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<4>::try_from_u32(12_345_678).unwrap();
assert_eq!(n.to_string(), "12345678");
Source

pub const fn try_from_u64(value: u64) -> Result<Self, BcdOverflowError>

Converts a u64 to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<8>::try_from_u64(1_000_000_000_000u64).unwrap();
assert_eq!(n.to_string(), "1000000000000");
Source

pub const fn try_from_u128(value: u128) -> Result<Self, BcdOverflowError>

Converts a u128 to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<20>::try_from_u128(u128::MAX).unwrap();
assert_eq!(n.to_string(), u128::MAX.to_string());
Source

pub const fn try_from_usize(value: usize) -> Result<Self, BcdOverflowError>

Converts a usize to BCD using the double-dabble algorithm.

Returns Err(BcdOverflowError) if value has more decimal digits than BYTES * 2 can hold.

§Examples
use const_bcd::Bcd;

let n = Bcd::<4>::try_from_usize(12345usize).unwrap();
assert_eq!(n.to_string(), "12345");
Source

pub const fn try_into_u8(self) -> Result<u8, BcdOverflowError>

Converts this BCD value to a u8.

Returns Err(BcdOverflowError) if the decoded value exceeds u8::MAX.

§Examples
use const_bcd::Bcd;

let n = Bcd::<1>::try_from_u8(42).unwrap();
assert_eq!(n.try_into_u8(), Ok(42u8));

// A large Bcd<2> value won't fit in a u8
let big = Bcd::<2>::try_from_u16(1000).unwrap();
assert!(big.try_into_u8().is_err());
Source

pub const fn try_into_u16(self) -> Result<u16, BcdOverflowError>

Converts this BCD value to a u16.

Returns Err(BcdOverflowError) if the decoded value exceeds u16::MAX.

§Examples
use const_bcd::Bcd;

let n = Bcd::<2>::try_from_u16(1234).unwrap();
assert_eq!(n.try_into_u16(), Ok(1234u16));
Source

pub const fn try_into_u32(self) -> Result<u32, BcdOverflowError>

Converts this BCD value to a u32.

Returns Err(BcdOverflowError) if the decoded value exceeds u32::MAX.

§Examples
use const_bcd::Bcd;

let n = Bcd::<4>::try_from_u32(100_000).unwrap();
assert_eq!(n.try_into_u32(), Ok(100_000u32));
Source

pub const fn try_into_u64(self) -> Result<u64, BcdOverflowError>

Converts this BCD value to a u64.

Returns Err(BcdOverflowError) if the decoded value exceeds u64::MAX.

§Examples
use const_bcd::Bcd;

let n = Bcd::<10>::try_from_u64(u64::MAX).unwrap();
assert_eq!(n.try_into_u64(), Ok(u64::MAX));
Source

pub const fn try_into_u128(self) -> Result<u128, BcdOverflowError>

Converts this BCD value to a u128.

Returns Err(BcdOverflowError) if the decoded value exceeds u128::MAX.

§Examples
use const_bcd::Bcd;

// A value larger than u64::MAX that still fits in Bcd<10> (max 10^20 - 1).
let v = 20_000_000_000_000_000_000u128;
let n = Bcd::<10>::try_from_u128(v).unwrap();
assert_eq!(n.try_into_u128(), Ok(v));
Source

pub const fn try_into_usize(self) -> Result<usize, BcdOverflowError>

Converts this BCD value to a usize.

Returns Err(BcdOverflowError) if the decoded value exceeds usize::MAX.

§Examples
use const_bcd::Bcd;

let n = Bcd::<4>::try_from_usize(99999usize).unwrap();
assert_eq!(n.try_into_usize(), Ok(99999usize));
Source§

impl Bcd<0>

Source

pub const fn into_u8(self) -> u8

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_u8(self) -> u8

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<0>

Source

pub const fn into_u16(self) -> u16

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_u16(self) -> u16

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<2>

Source

pub const fn into_u16(self) -> u16

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<0>

Source

pub const fn into_u32(self) -> u32

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_u32(self) -> u32

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<2>

Source

pub const fn into_u32(self) -> u32

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<3>

Source

pub const fn into_u32(self) -> u32

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<4>

Source

pub const fn into_u32(self) -> u32

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<0>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<2>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<3>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<4>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<5>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<6>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<7>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<8>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<9>

Source

pub const fn into_u64(self) -> u64

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<0>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<2>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<3>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<4>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<5>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<6>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<7>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<8>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<9>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<10>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<11>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<12>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<13>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<14>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<15>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<16>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<17>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<18>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<19>

Source

pub const fn into_u128(self) -> u128

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<0>

Source

pub const fn into_usize(self) -> usize

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<1>

Source

pub const fn into_usize(self) -> usize

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Source§

impl Bcd<2>

Source

pub const fn into_usize(self) -> usize

Infallibly converts this BCD value to a primitive integer.

Available only for BYTES values whose maximum representable BCD value is statically guaranteed to fit in the target primitive, so this method cannot overflow.

Trait Implementations§

Source§

impl<const BYTES: usize> Clone for Bcd<BYTES>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const BYTES: usize> Copy for Bcd<BYTES>

Source§

impl<const BYTES: usize> Debug for Bcd<BYTES>

Source§

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

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

impl<const BYTES: usize> Display for Bcd<BYTES>

Formats the BCD value as a decimal string.

Behaves like a native unsigned integer: width, alignment, sign (+), and numeric zero-padding are honored via core::fmt::Formatter::pad_integral.

§Examples

use const_bcd::Bcd;

let n = Bcd::<4>::try_from_u32(42).unwrap();
assert_eq!(format!("{n}"),    "42");
assert_eq!(format!("{n:8}"),  "      42");
assert_eq!(format!("{n:08}"), "00000042");
assert_eq!(format!("{n:<8}"), "42      ");
assert_eq!(format!("{n:+}"),  "+42");

// Zero displays as "0", not ""
let zero = Bcd::<2>::try_from_u16(0).unwrap();
assert_eq!(format!("{zero}"), "0");
Source§

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

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

impl<const BYTES: usize> Eq for Bcd<BYTES>

Source§

impl<const BYTES: usize> Hash for Bcd<BYTES>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const BYTES: usize> Ord for Bcd<BYTES>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<const BYTES: usize> PartialEq for Bcd<BYTES>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<const BYTES: usize> PartialOrd for Bcd<BYTES>

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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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<const BYTES: usize> StructuralPartialEq for Bcd<BYTES>

Auto Trait Implementations§

§

impl<const BYTES: usize> Freeze for Bcd<BYTES>
where [u8; BYTES]: Freeze,

§

impl<const BYTES: usize> RefUnwindSafe for Bcd<BYTES>

§

impl<const BYTES: usize> Send for Bcd<BYTES>
where [u8; BYTES]: Send,

§

impl<const BYTES: usize> Sync for Bcd<BYTES>
where [u8; BYTES]: Sync,

§

impl<const BYTES: usize> Unpin for Bcd<BYTES>
where [u8; BYTES]: Unpin,

§

impl<const BYTES: usize> UnsafeUnpin for Bcd<BYTES>
where [u8; BYTES]: UnsafeUnpin,

§

impl<const BYTES: usize> UnwindSafe for Bcd<BYTES>
where [u8; BYTES]: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.