Skip to content

Commit 2740088

Browse files
authored
fixed abs() (#208)
Co-authored-by: lif <>
1 parent 2d357d4 commit 2740088

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/fixed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,14 @@ impl_common_fixed_ops!(u32);
274274
macro_rules! impl_signed_fixed_ops {
275275
($t:ty, $unsigned:ty) => {
276276
impl<const B: u32> Fixed<$t, B> {
277+
/// Absolute value.
278+
#[inline]
279+
#[must_use]
280+
#[cfg_attr(feature = "track_caller", track_caller)]
281+
pub const fn abs(self) -> Self {
282+
Self(self.0.abs())
283+
}
284+
277285
/// Negate.
278286
#[inline]
279287
#[must_use]

0 commit comments

Comments
 (0)