Fix negative symbol bug in `FromStr` display implementation.
The negative symbol wasn't there when `int_part` was equal to zero. Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
This commit is contained in:
parent
a915bc194d
commit
6902bf826c
|
@ -63,9 +63,13 @@ impl fmt::Display for Decimal {
|
|||
let ten = 10i64.pow(self.exponent as u32);
|
||||
let int_part = self.mantissa / ten;
|
||||
let dec_part = (self.mantissa % ten).abs();
|
||||
if int_part == 0 && self.mantissa < 0 {
|
||||
write!(f, "-{}.{:02$}", int_part, dec_part, self.exponent)
|
||||
} else {
|
||||
write!(f, "{}.{:02$}", int_part, dec_part, self.exponent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Add for Decimal {
|
||||
type Output = Decimal;
|
||||
|
|
Loading…
Reference in New Issue