Skip to main content

IOUNumber

Struct IOUNumber 

Source
#[repr(C)]
pub struct IOUNumber(pub [u8; 8]);
Expand description

The 8-byte value field of an XRPL fungible token (IOU) amount.

This is the leading 8 bytes of a serialized IOU STAmount (the value, without the trailing currency and issuer). It is not an STAmount, and it is a different encoding from the 12-byte STNumber used for host arithmetic.

The format is [Type:1][Sign:1][Exponent:8][Mantissa:54] bits, big-endian.

§Important

This type is a read-only wire representation. Arithmetic MUST be performed through the host’s Number (STNumber) type, which uses rippled’s Number class to stay consensus-exact. The accessors below expose the raw encoded fields for inspection only.

§Format Details

  • Type bit (bit 63): Always 1 for fungible tokens
  • Sign bit (bit 62): 1 = positive, 0 = negative
  • Exponent (bits 61-54): 8 bits, biased by 97 (real exponent range -96 to +80)
  • Mantissa (bits 53-0): 54 bits providing ~16 decimal digits precision

§Special Values

  • Zero: 0x8000000000000000 (mantissa is 0)
  • Maximum: ~9.999999999999999 × 10^80
  • Minimum positive: ~1.0 × 10^-81

§Derived Traits

  • PartialEq, Eq: Enable comparisons (bitwise comparison only)
  • Debug, Clone: Standard traits for development and consistency

Note: PartialEq and Eq perform bitwise comparison only. For semantic comparison of amounts (e.g., handling different representations of zero), convert to Number and compare there.

Tuple Fields§

§0: [u8; 8]

Implementations§

Source§

impl IOUNumber

Source

pub fn is_positive(&self) -> bool

Returns true if the sign bit marks this value as positive.

Note the sign bit is meaningless for zero; prefer IOUNumber::is_zero to test for zero.

Source

pub fn is_zero(&self) -> bool

Returns true if this value is zero (mantissa is 0).

Source

pub fn exponent(&self) -> i32

Returns the real (unbiased) base-10 exponent.

WARNING: prefer the host Number type for arithmetic; this exposes the raw encoded field.

Source

pub fn mantissa(&self) -> u64

Returns the 54-bit unsigned mantissa.

WARNING: prefer the host Number type for arithmetic; this exposes the raw encoded field.

Trait Implementations§

Source§

impl Clone for IOUNumber

Source§

fn clone(&self) -> IOUNumber

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 Debug for IOUNumber

Source§

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

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

impl Eq for IOUNumber

Source§

impl From<[u8; 8]> for IOUNumber

Source§

fn from(value: [u8; 8]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for IOUNumber

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IOUNumber

Auto Trait Implementations§

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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, 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.