diff --git a/core/expression/src/functions/internal.rs b/core/expression/src/functions/internal.rs index 387ae126..0e467ad2 100644 --- a/core/expression/src/functions/internal.rs +++ b/core/expression/src/functions/internal.rs @@ -313,7 +313,7 @@ pub(crate) mod imp { #[cfg(feature = "regex-lite")] use regex_lite::Regex; use rust_decimal::prelude::{FromPrimitive, ToPrimitive}; - use rust_decimal::Decimal; + use rust_decimal::{Decimal, RoundingStrategy}; use rust_decimal_macros::dec; use std::collections::BTreeMap; use std::rc::Rc; @@ -473,7 +473,10 @@ pub(crate) mod imp { .transpose()? .unwrap_or(0); - Ok(V::Number(a.round_dp(dp))) + Ok(V::Number(a.round_dp_with_strategy( + dp, + RoundingStrategy::MidpointAwayFromZero, + ))) } pub fn trunc(args: Arguments) -> anyhow::Result { diff --git a/core/expression/tests/data/standard.csv b/core/expression/tests/data/standard.csv index 6f03b62c..99ff24d9 100644 --- a/core/expression/tests/data/standard.csv +++ b/core/expression/tests/data/standard.csv @@ -441,6 +441,10 @@ round(7.6);; 8 round(-7.4);; -7 round(-7.5);; -8 round(-7.6);; -8 +round(0.5);;1 +round(-0.5);;-1 +round(1.5);;2 +round(-1.5);;-2 round(7.444, 0);; 7 round(7.444, 1);; 7.4