diff --git a/lib/src/sql/number.rs b/lib/src/sql/number.rs index 415b8872..4ddb115d 100644 --- a/lib/src/sql/number.rs +++ b/lib/src/sql/number.rs @@ -389,6 +389,14 @@ impl Number { } } + pub fn fixed(self, precision: usize) -> Number { + match self { + Number::Int(v) => format!("{:.1$}", v, precision).into(), + Number::Float(v) => format!("{:.1$}", v, precision).into(), + Number::Decimal(v) => format!("{:.1$}", v, precision).into(), + } + } + pub fn sqrt(self) -> Self { match self { Number::Int(v) => (v as f64).sqrt().into(), @@ -411,18 +419,6 @@ impl Number { (v, p) => Number::Float(v.as_float().pow(p.as_float())), } } - - // ----------------------------------- - // - // ----------------------------------- - - pub fn fixed(self, precision: usize) -> Number { - match self { - Number::Int(v) => format!("{:.1$}", v, precision).into(), - Number::Float(v) => format!("{:.1$}", v, precision).into(), - Number::Decimal(v) => v.round(precision as i64).into(), - } - } } impl Eq for Number {}