Skip to content

Commit

Permalink
macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Jun 3, 2024
1 parent 35018e6 commit 5e6d9f1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/gba_fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ macro_rules! impl_signed_fixed_ops {
impl<const B: u32> core::fmt::Debug for Fixed<$t, B> {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
let whole: $t = self.trunc().into_raw() >> B;
let fract: $t = self.fract().into_raw();
let whole: $t = self.trunc().to_bits() >> B;
let fract: $t = self.fract().to_bits();
let divisor: $t = 1 << B;
if self.is_negative() {
let whole = whole.unsigned_abs();
write!(f, "-({whole}+{fract}/{divisor})")
write!(f, "-({whole}+({fract}/{divisor}))")
} else {
write!(f, "{whole}+{fract}/{divisor}")
write!(f, "{whole}+({fract}/{divisor})")
}
}
}
Expand Down Expand Up @@ -350,10 +350,10 @@ macro_rules! impl_unsigned_fixed_ops {
impl<const B: u32> core::fmt::Debug for Fixed<$t, B> {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
let whole: $t = self.trunc().into_raw() >> B;
let fract: $t = self.fract().into_raw();
let whole: $t = self.trunc().to_bits() >> B;
let fract: $t = self.fract().to_bits();
let divisor: $t = 1 << B;
write!(f, "{whole}+{fract}/{divisor}")
write!(f, "{whole}+({fract}/{divisor})")
}
}
};
Expand Down

0 comments on commit 5e6d9f1

Please sign in to comment.