diff --git a/src/lib.rs b/src/lib.rs index 6d1b2e2..f10d370 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ pub mod prelude { pub type BigInt = fastnum::I512; pub type BigUint = fastnum::U512; - pub type BigDecimal = fastnum::UD512; + pub type BigDecimal = fastnum::D512; pub type RoundingMode = fastnum::decimal::RoundingMode; } diff --git a/src/utils/types.rs b/src/utils/types.rs index 51e2931..e9e921e 100644 --- a/src/utils/types.rs +++ b/src/utils/types.rs @@ -1,11 +1,14 @@ use crate::prelude::{BigDecimal, BigInt, BigUint}; use alloy_primitives::U256; -use fastnum::decimal::Context; +use fastnum::decimal::{Context, Sign}; #[inline] #[must_use] pub const fn to_big_decimal(value: BigInt) -> BigDecimal { - BigDecimal::from_parts(value.to_bits(), 0, Context::default()) + match value.is_negative() { + false => BigDecimal::from_parts(value.to_bits(), 0, Sign::Plus, Context::default()), + true => BigDecimal::from_parts(value.to_bits(), 0, Sign::Minus, Context::default()), + } } #[inline]