mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Fix formatting of fixnums in the range (-1, 0)
This commit is contained in:
parent
ed218102ab
commit
61ed85b032
|
@ -537,6 +537,11 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Display for Num<I, N> {
|
||||||
// So we have to add 1 to the integral bit, and take 1 - fractional bit
|
// So we have to add 1 to the integral bit, and take 1 - fractional bit
|
||||||
if fractional != I::zero() && integral < I::zero() {
|
if fractional != I::zero() && integral < I::zero() {
|
||||||
integral = integral + I::one();
|
integral = integral + I::one();
|
||||||
|
if integral == I::zero() {
|
||||||
|
// If the number is in the range (-1, 0), then we just bumped `integral` from -1 to 0,
|
||||||
|
// so we need to compensate for the missing negative sign.
|
||||||
|
write!(f, "-")?;
|
||||||
|
}
|
||||||
fractional = (I::one() << N) - fractional;
|
fractional = (I::one() << N) - fractional;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue