mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
uucore/format: remove Display impl
of ExtendedBigDecimal
This commit is contained in:
parent
eaa8332be4
commit
636e4a777b
1 changed files with 0 additions and 32 deletions
|
@ -21,7 +21,6 @@
|
||||||
//! assert_eq!(summand1 + summand2, ExtendedBigDecimal::Infinity);
|
//! assert_eq!(summand1 + summand2, ExtendedBigDecimal::Infinity);
|
||||||
//! ```
|
//! ```
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::Display;
|
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::ops::Neg;
|
use std::ops::Neg;
|
||||||
|
|
||||||
|
@ -110,25 +109,6 @@ impl ExtendedBigDecimal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for ExtendedBigDecimal {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Self::BigDecimal(x) => {
|
|
||||||
let (n, p) = x.as_bigint_and_exponent();
|
|
||||||
match p {
|
|
||||||
0 => Self::BigDecimal(BigDecimal::new(n * 10, 1)).fmt(f),
|
|
||||||
_ => x.fmt(f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Self::Infinity => f32::INFINITY.fmt(f),
|
|
||||||
Self::MinusInfinity => f32::NEG_INFINITY.fmt(f),
|
|
||||||
Self::MinusZero => (-0.0f32).fmt(f),
|
|
||||||
Self::Nan => "nan".fmt(f),
|
|
||||||
Self::MinusNan => "-nan".fmt(f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Zero for ExtendedBigDecimal {
|
impl Zero for ExtendedBigDecimal {
|
||||||
fn zero() -> Self {
|
fn zero() -> Self {
|
||||||
Self::BigDecimal(BigDecimal::zero())
|
Self::BigDecimal(BigDecimal::zero())
|
||||||
|
@ -281,16 +261,4 @@ mod tests {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_display() {
|
|
||||||
assert_eq!(
|
|
||||||
format!("{}", ExtendedBigDecimal::BigDecimal(BigDecimal::zero())),
|
|
||||||
"0.0"
|
|
||||||
);
|
|
||||||
assert_eq!(format!("{}", ExtendedBigDecimal::Infinity), "inf");
|
|
||||||
assert_eq!(format!("{}", ExtendedBigDecimal::MinusInfinity), "-inf");
|
|
||||||
assert_eq!(format!("{}", ExtendedBigDecimal::Nan), "nan");
|
|
||||||
assert_eq!(format!("{}", ExtendedBigDecimal::MinusZero), "-0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue