macro_rules! decl_decimal_sign_methods {
(wide $Type:ident, $Storage:ty) => {
impl<const SCALE: u32> $Type<SCALE> {
#[inline]
#[must_use]
pub const fn abs(self) -> Self {
if self.0.is_negative() {
match self.0.checked_neg() {
Some(v) => Self(v),
None => panic!("attempt to compute the absolute value with overflow"),
}
} else {
self
}
}
#[inline]
#[must_use]
pub fn signum(self) -> Self {
if self.0.is_positive() {
Self::ONE
} else if self.0.is_negative() {
Self(-Self::multiplier())
} else {
Self::ZERO
}
}
#[inline]
#[must_use]
pub const fn is_positive(self) -> bool {
self.0.is_positive()
}
#[inline]
#[must_use]
pub const fn is_negative(self) -> bool {
self.0.is_negative()
}
}
};
}
pub(crate) use decl_decimal_sign_methods;