mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 16:02:40 +00:00
fix: update rounding strategy
This commit is contained in:
@@ -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<V> {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 14 and column 13.
|
Reference in New Issue
Block a user