pub struct Decimal { /* private fields */ }Expand description
Decimal represents a 128 bit representation of a fixed-precision decimal number.
The finite set of values of type Decimal are of the form m / 10e,
where m is an integer such that -296 < m < 296, and e is an integer
between 0 and 28 inclusive.
Implementations§
Source§impl Decimal
impl Decimal
Sourcepub fn new(num: i64, scale: u32) -> Decimal
pub fn new(num: i64, scale: u32) -> Decimal
Returns a Decimal with a 64 bit m representation and corresponding e scale.
§Arguments
num- An i64 that represents themportion of the decimal numberscale- A u32 representing theeportion of the decimal number.
§Panics
This function panics if scale is > 28.
§Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
assert_eq!(pi.to_string(), "3.141");Sourcepub fn from_i128_with_scale(num: i128, scale: u32) -> Decimal
pub fn from_i128_with_scale(num: i128, scale: u32) -> Decimal
Creates a Decimal using a 128 bit signed m representation and corresponding e scale.
§Arguments
num- An i128 that represents themportion of the decimal numberscale- A u32 representing theeportion of the decimal number.
§Panics
This function panics if scale is > 28 or if num exceeds the maximum supported 96 bits.
§Example
use rust_decimal::Decimal;
let pi = Decimal::from_i128_with_scale(3141i128, 3);
assert_eq!(pi.to_string(), "3.141");Sourcepub const fn from_parts(
lo: u32,
mid: u32,
hi: u32,
negative: bool,
scale: u32,
) -> Decimal
pub const fn from_parts( lo: u32, mid: u32, hi: u32, negative: bool, scale: u32, ) -> Decimal
Returns a Decimal using the instances constituent parts.
§Arguments
lo- The low 32 bits of a 96-bit integer.mid- The middle 32 bits of a 96-bit integer.hi- The high 32 bits of a 96-bit integer.negative-trueto indicate a negative number.scale- A power of 10 ranging from 0 to 28.
§Caution: Undefined behavior
While a scale greater than 28 can be passed in, it will be automatically capped by this function at the maximum precision. The library opts towards this functionality as opposed to a panic to ensure that the function can be treated as constant. This may lead to undefined behavior in downstream applications and should be treated with caution.
§Example
use rust_decimal::Decimal;
let pi = Decimal::from_parts(1102470952, 185874565, 1703060790, false, 28);
assert_eq!(pi.to_string(), "3.1415926535897932384626433832");Sourcepub fn from_scientific(value: &str) -> Result<Decimal, Error>
pub fn from_scientific(value: &str) -> Result<Decimal, Error>
Returns a Result which if successful contains the Decimal constitution of
the scientific notation provided by value.
§Arguments
value- The scientific notation of theDecimal.
§Example
use rust_decimal::Decimal;
let value = Decimal::from_scientific("9.7e-7").unwrap();
assert_eq!(value.to_string(), "0.00000097");Sourcepub const fn scale(&self) -> u32
pub const fn scale(&self) -> u32
Returns the scale of the decimal number, otherwise known as e.
§Example
use rust_decimal::Decimal;
let num = Decimal::new(1234, 3);
assert_eq!(num.scale(), 3u32);Sourcepub const fn mantissa(&self) -> i128
pub const fn mantissa(&self) -> i128
Returns the mantissa of the decimal number.
§Example
use rust_decimal::prelude::*;
let num = Decimal::from_str("-1.2345678").unwrap();
assert_eq!(num.mantissa(), -12345678i128);
assert_eq!(num.scale(), 7);Sourcepub const fn is_zero(&self) -> bool
pub const fn is_zero(&self) -> bool
Returns true if this Decimal number is equivalent to zero.
§Example
use rust_decimal::prelude::*;
let num = Decimal::ZERO;
assert!(num.is_zero());Sourcepub fn set_sign(&mut self, positive: bool)
👎Deprecated since 1.4.0: please use set_sign_positive instead
pub fn set_sign(&mut self, positive: bool)
set_sign_positive insteadSourcepub fn set_sign_positive(&mut self, positive: bool)
pub fn set_sign_positive(&mut self, positive: bool)
Sourcepub fn set_sign_negative(&mut self, negative: bool)
pub fn set_sign_negative(&mut self, negative: bool)
Sourcepub fn rescale(&mut self, scale: u32)
pub fn rescale(&mut self, scale: u32)
Modifies the Decimal to the given scale, attempting to do so without changing the
underlying number itself.
Note that setting the scale to something less then the current Decimals scale will
cause the newly created Decimal to have some rounding.
Scales greater than the maximum precision supported by Decimal will be automatically
rounded to Decimal::MAX_PRECISION.
Rounding leverages the half up strategy.
§Arguments
scale: The scale to use for the newDecimalnumber.
§Example
use rust_decimal::Decimal;
let mut number = Decimal::new(1_123, 3);
number.rescale(6);
assert_eq!(number, Decimal::new(1_123_000, 6));
let mut round = Decimal::new(145, 2);
round.rescale(1);
assert_eq!(round, Decimal::new(15, 1));Sourcepub const fn serialize(&self) -> [u8; 16]
pub const fn serialize(&self) -> [u8; 16]
Returns a serialized version of the decimal number. The resulting byte array will have the following representation:
- Bytes 1-4: flags
- Bytes 5-8: lo portion of
m - Bytes 9-12: mid portion of
m - Bytes 13-16: high portion of
m
Sourcepub const fn deserialize(bytes: [u8; 16]) -> Decimal
pub const fn deserialize(bytes: [u8; 16]) -> Decimal
Deserializes the given bytes into a decimal number. The deserialized byte representation must be 16 bytes and adhere to the following convention:
- Bytes 1-4: flags
- Bytes 5-8: lo portion of
m - Bytes 9-12: mid portion of
m - Bytes 13-16: high portion of
m
Sourcepub fn is_negative(&self) -> bool
👎Deprecated since 0.6.3: please use is_sign_negative instead
pub fn is_negative(&self) -> bool
is_sign_negative insteadReturns true if the decimal is negative.
Sourcepub fn is_positive(&self) -> bool
👎Deprecated since 0.6.3: please use is_sign_positive instead
pub fn is_positive(&self) -> bool
is_sign_positive insteadReturns true if the decimal is positive.
Sourcepub const fn is_sign_negative(&self) -> bool
pub const fn is_sign_negative(&self) -> bool
Returns true if the sign bit of the decimal is negative.
Sourcepub const fn is_sign_positive(&self) -> bool
pub const fn is_sign_positive(&self) -> bool
Returns true if the sign bit of the decimal is positive.
Sourcepub const fn min_value() -> Decimal
👎Deprecated since 1.12.0: Use the associated constant Decimal::MIN
pub const fn min_value() -> Decimal
Returns the minimum possible number that Decimal can represent.
Sourcepub const fn max_value() -> Decimal
👎Deprecated since 1.12.0: Use the associated constant Decimal::MAX
pub const fn max_value() -> Decimal
Returns the maximum possible number that Decimal can represent.
Sourcepub fn trunc(&self) -> Decimal
pub fn trunc(&self) -> Decimal
Returns a new Decimal integral with no fractional portion.
This is a true truncation whereby no rounding is performed.
§Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
let trunc = Decimal::new(3, 0);
// note that it returns a decimal
assert_eq!(pi.trunc(), trunc);Sourcepub fn fract(&self) -> Decimal
pub fn fract(&self) -> Decimal
Returns a new Decimal representing the fractional portion of the number.
§Example
use rust_decimal::Decimal;
let pi = Decimal::new(3141, 3);
let fract = Decimal::new(141, 3);
// note that it returns a decimal
assert_eq!(pi.fract(), fract);Sourcepub fn abs(&self) -> Decimal
pub fn abs(&self) -> Decimal
Computes the absolute value of self.
§Example
use rust_decimal::Decimal;
let num = Decimal::new(-3141, 3);
assert_eq!(num.abs().to_string(), "3.141");Sourcepub fn floor(&self) -> Decimal
pub fn floor(&self) -> Decimal
Returns the largest integer less than or equal to a number.
§Example
use rust_decimal::Decimal;
let num = Decimal::new(3641, 3);
assert_eq!(num.floor().to_string(), "3");Sourcepub fn ceil(&self) -> Decimal
pub fn ceil(&self) -> Decimal
Returns the smallest integer greater than or equal to a number.
§Example
use rust_decimal::Decimal;
let num = Decimal::new(3141, 3);
assert_eq!(num.ceil().to_string(), "4");
let num = Decimal::new(3, 0);
assert_eq!(num.ceil().to_string(), "3");Sourcepub fn max(self, other: Decimal) -> Decimal
pub fn max(self, other: Decimal) -> Decimal
Returns the maximum of the two numbers.
use rust_decimal::Decimal;
let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(y, x.max(y));Sourcepub fn min(self, other: Decimal) -> Decimal
pub fn min(self, other: Decimal) -> Decimal
Returns the minimum of the two numbers.
use rust_decimal::Decimal;
let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(x, x.min(y));Sourcepub fn normalize(&self) -> Decimal
pub fn normalize(&self) -> Decimal
Strips any trailing zero’s from a Decimal and converts -0 to 0.
§Example
use rust_decimal::Decimal;
let number = Decimal::new(3100, 3);
// note that it returns a decimal, without the extra scale
assert_eq!(number.normalize().to_string(), "3.1");Sourcepub fn round(&self) -> Decimal
pub fn round(&self) -> Decimal
Returns a new Decimal number with no fractional portion (i.e. an integer).
Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
§Example
use rust_decimal::Decimal;
// Demonstrating bankers rounding...
let number_down = Decimal::new(65, 1);
let number_up = Decimal::new(75, 1);
assert_eq!(number_down.round().to_string(), "6");
assert_eq!(number_up.round().to_string(), "8");Sourcepub fn round_dp_with_strategy(
&self,
dp: u32,
strategy: RoundingStrategy,
) -> Decimal
pub fn round_dp_with_strategy( &self, dp: u32, strategy: RoundingStrategy, ) -> Decimal
Returns a new Decimal number with the specified number of decimal points for fractional
portion.
Rounding is performed using the provided RoundingStrategy
§Arguments
dp: the number of decimal points to round to.strategy: theRoundingStrategyto use.
§Example
use rust_decimal::{Decimal, RoundingStrategy};
use core::str::FromStr;
let tax = Decimal::from_str("3.4395").unwrap();
assert_eq!(tax.round_dp_with_strategy(2, RoundingStrategy::MidpointAwayFromZero).to_string(), "3.44");Sourcepub fn round_dp(&self, dp: u32) -> Decimal
pub fn round_dp(&self, dp: u32) -> Decimal
Returns a new Decimal number with the specified number of decimal points for fractional portion.
Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
§Arguments
dp: the number of decimal points to round to.
§Example
use rust_decimal::Decimal;
use core::str::FromStr;
let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap();
assert_eq!(pi.round_dp(2).to_string(), "3.14");Sourcepub const fn unpack(&self) -> UnpackedDecimal
pub const fn unpack(&self) -> UnpackedDecimal
Convert Decimal to an internal representation of the underlying struct. This is useful
for debugging the internal state of the object.
§Important Disclaimer
This is primarily intended for library maintainers. The internal representation of a
Decimal is considered “unstable” for public use.
§Example
use rust_decimal::Decimal;
use core::str::FromStr;
let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap();
assert_eq!(format!("{:?}", pi), "3.1415926535897932384626433832");
assert_eq!(format!("{:?}", pi.unpack()), "UnpackedDecimal { \
negative: false, scale: 28, hi: 1703060790, mid: 185874565, lo: 1102470952 \
}");Sourcepub fn checked_add(self, other: Decimal) -> Option<Decimal>
pub fn checked_add(self, other: Decimal) -> Option<Decimal>
Checked addition. Computes self + other, returning None if overflow occurred.
Sourcepub fn checked_sub(self, other: Decimal) -> Option<Decimal>
pub fn checked_sub(self, other: Decimal) -> Option<Decimal>
Checked subtraction. Computes self - other, returning None if overflow occurred.
Sourcepub fn checked_mul(self, other: Decimal) -> Option<Decimal>
pub fn checked_mul(self, other: Decimal) -> Option<Decimal>
Checked multiplication. Computes self * other, returning None if overflow occurred.
Sourcepub fn checked_div(self, other: Decimal) -> Option<Decimal>
pub fn checked_div(self, other: Decimal) -> Option<Decimal>
Checked division. Computes self / other, returning None if other == 0.0 or the
division results in overflow.
Sourcepub fn checked_rem(self, other: Decimal) -> Option<Decimal>
pub fn checked_rem(self, other: Decimal) -> Option<Decimal>
Checked remainder. Computes self % other, returning None if other == 0.0.
pub fn from_str_radix(str: &str, radix: u32) -> Result<Decimal, Error>
Trait Implementations§
Source§impl<'a> AddAssign<&'a Decimal> for &'a mut Decimal
impl<'a> AddAssign<&'a Decimal> for &'a mut Decimal
Source§fn add_assign(&mut self, other: &'a Decimal)
fn add_assign(&mut self, other: &'a Decimal)
+= operation. Read moreSource§impl<'a> AddAssign<&'a Decimal> for Decimal
impl<'a> AddAssign<&'a Decimal> for Decimal
Source§fn add_assign(&mut self, other: &'a Decimal)
fn add_assign(&mut self, other: &'a Decimal)
+= operation. Read moreSource§impl<'a> AddAssign<Decimal> for &'a mut Decimal
impl<'a> AddAssign<Decimal> for &'a mut Decimal
Source§fn add_assign(&mut self, other: Decimal)
fn add_assign(&mut self, other: Decimal)
+= operation. Read moreSource§impl AddAssign for Decimal
impl AddAssign for Decimal
Source§fn add_assign(&mut self, other: Decimal)
fn add_assign(&mut self, other: Decimal)
+= operation. Read moreSource§impl CheckedAdd for Decimal
impl CheckedAdd for Decimal
Source§impl CheckedDiv for Decimal
impl CheckedDiv for Decimal
Source§impl CheckedMul for Decimal
impl CheckedMul for Decimal
Source§impl CheckedRem for Decimal
impl CheckedRem for Decimal
Source§impl CheckedSub for Decimal
impl CheckedSub for Decimal
Source§impl<'de> Deserialize<'de> for Decimal
impl<'de> Deserialize<'de> for Decimal
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Decimal, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Decimal, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'a> DivAssign<&'a Decimal> for &'a mut Decimal
impl<'a> DivAssign<&'a Decimal> for &'a mut Decimal
Source§fn div_assign(&mut self, other: &'a Decimal)
fn div_assign(&mut self, other: &'a Decimal)
/= operation. Read moreSource§impl<'a> DivAssign<&'a Decimal> for Decimal
impl<'a> DivAssign<&'a Decimal> for Decimal
Source§fn div_assign(&mut self, other: &'a Decimal)
fn div_assign(&mut self, other: &'a Decimal)
/= operation. Read moreSource§impl<'a> DivAssign<Decimal> for &'a mut Decimal
impl<'a> DivAssign<Decimal> for &'a mut Decimal
Source§fn div_assign(&mut self, other: Decimal)
fn div_assign(&mut self, other: Decimal)
/= operation. Read moreSource§impl DivAssign for Decimal
impl DivAssign for Decimal
Source§fn div_assign(&mut self, other: Decimal)
fn div_assign(&mut self, other: Decimal)
/= operation. Read moreSource§impl FromPrimitive for Decimal
impl FromPrimitive for Decimal
Source§fn from_i32(n: i32) -> Option<Decimal>
fn from_i32(n: i32) -> Option<Decimal>
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i64(n: i64) -> Option<Decimal>
fn from_i64(n: i64) -> Option<Decimal>
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Decimal>
fn from_i128(n: i128) -> Option<Decimal>
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u32(n: u32) -> Option<Decimal>
fn from_u32(n: u32) -> Option<Decimal>
u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u64(n: u64) -> Option<Decimal>
fn from_u64(n: u64) -> Option<Decimal>
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Decimal>
fn from_u128(n: u128) -> Option<Decimal>
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Decimal>
fn from_f32(n: f32) -> Option<Decimal>
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Decimal>
fn from_f64(n: f64) -> Option<Decimal>
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl<'a> MulAssign<&'a Decimal> for &'a mut Decimal
impl<'a> MulAssign<&'a Decimal> for &'a mut Decimal
Source§fn mul_assign(&mut self, other: &'a Decimal)
fn mul_assign(&mut self, other: &'a Decimal)
*= operation. Read moreSource§impl<'a> MulAssign<&'a Decimal> for Decimal
impl<'a> MulAssign<&'a Decimal> for Decimal
Source§fn mul_assign(&mut self, other: &'a Decimal)
fn mul_assign(&mut self, other: &'a Decimal)
*= operation. Read moreSource§impl<'a> MulAssign<Decimal> for &'a mut Decimal
impl<'a> MulAssign<Decimal> for &'a mut Decimal
Source§fn mul_assign(&mut self, other: Decimal)
fn mul_assign(&mut self, other: Decimal)
*= operation. Read moreSource§impl MulAssign for Decimal
impl MulAssign for Decimal
Source§fn mul_assign(&mut self, other: Decimal)
fn mul_assign(&mut self, other: Decimal)
*= operation. Read moreSource§impl Ord for Decimal
impl Ord for Decimal
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
Source§impl<'a> RemAssign<&'a Decimal> for &'a mut Decimal
impl<'a> RemAssign<&'a Decimal> for &'a mut Decimal
Source§fn rem_assign(&mut self, other: &'a Decimal)
fn rem_assign(&mut self, other: &'a Decimal)
%= operation. Read moreSource§impl<'a> RemAssign<&'a Decimal> for Decimal
impl<'a> RemAssign<&'a Decimal> for Decimal
Source§fn rem_assign(&mut self, other: &'a Decimal)
fn rem_assign(&mut self, other: &'a Decimal)
%= operation. Read moreSource§impl<'a> RemAssign<Decimal> for &'a mut Decimal
impl<'a> RemAssign<Decimal> for &'a mut Decimal
Source§fn rem_assign(&mut self, other: Decimal)
fn rem_assign(&mut self, other: Decimal)
%= operation. Read moreSource§impl RemAssign for Decimal
impl RemAssign for Decimal
Source§fn rem_assign(&mut self, other: Decimal)
fn rem_assign(&mut self, other: Decimal)
%= operation. Read moreSource§impl Serialize for Decimal
impl Serialize for Decimal
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl Signed for Decimal
impl Signed for Decimal
Source§fn abs_sub(&self, other: &Decimal) -> Decimal
fn abs_sub(&self, other: &Decimal) -> Decimal
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Source§impl<'a> SubAssign<&'a Decimal> for &'a mut Decimal
impl<'a> SubAssign<&'a Decimal> for &'a mut Decimal
Source§fn sub_assign(&mut self, other: &'a Decimal)
fn sub_assign(&mut self, other: &'a Decimal)
-= operation. Read moreSource§impl<'a> SubAssign<&'a Decimal> for Decimal
impl<'a> SubAssign<&'a Decimal> for Decimal
Source§fn sub_assign(&mut self, other: &'a Decimal)
fn sub_assign(&mut self, other: &'a Decimal)
-= operation. Read moreSource§impl<'a> SubAssign<Decimal> for &'a mut Decimal
impl<'a> SubAssign<Decimal> for &'a mut Decimal
Source§fn sub_assign(&mut self, other: Decimal)
fn sub_assign(&mut self, other: Decimal)
-= operation. Read moreSource§impl SubAssign for Decimal
impl SubAssign for Decimal
Source§fn sub_assign(&mut self, other: Decimal)
fn sub_assign(&mut self, other: Decimal)
-= operation. Read moreSource§impl ToPrimitive for Decimal
impl ToPrimitive for Decimal
Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self to an i64. If the value cannot be
represented by an i64, then None is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self to an i128. If the value cannot be
represented by an i128 (i64 under the default implementation), then
None is returned. Read moreSource§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self to a u64. If the value cannot be
represented by a u64, then None is returned.Source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self to a u128. If the value cannot be
represented by a u128 (u64 under the default implementation), then
None is returned. Read moreSource§fn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
self to an f64. Overflows may map to positive
or negative inifinity, otherwise None is returned if the value cannot
be represented by an f64. Read moreSource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self to an isize. If the value cannot be
represented by an isize, then None is returned.Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self to an i8. If the value cannot be
represented by an i8, then None is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self to an i16. If the value cannot be
represented by an i16, then None is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self to an i32. If the value cannot be
represented by an i32, then None is returned.Source§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self to a usize. If the value cannot be
represented by a usize, then None is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self to a u8. If the value cannot be
represented by a u8, then None is returned.Source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self to a u16. If the value cannot be
represented by a u16, then None is returned.