diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index 47036f28..355b6007 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -537,6 +537,11 @@ impl Display for Num { // So we have to add 1 to the integral bit, and take 1 - fractional bit if fractional != I::zero() && integral < I::zero() { 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; }