Skip to content

Commit

Permalink
fixed abs() (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: lif <>
  • Loading branch information
lifning authored Feb 5, 2025
1 parent 2d357d4 commit 2740088
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ impl_common_fixed_ops!(u32);
macro_rules! impl_signed_fixed_ops {
($t:ty, $unsigned:ty) => {
impl<const B: u32> Fixed<$t, B> {
/// Absolute value.
#[inline]
#[must_use]
#[cfg_attr(feature = "track_caller", track_caller)]
pub const fn abs(self) -> Self {
Self(self.0.abs())
}

/// Negate.
#[inline]
#[must_use]
Expand Down

0 comments on commit 2740088

Please sign in to comment.