You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears the round_sf_with_strategy does not do appropriate checking on scale and can return invalid values.
Example:
let value = Decimal::new(1,20).round_sf_with_strategy(12,RoundingStrategy::MidpointAwayFromZero).unwrap();assert!(value.scale() <= 28);print!("{value}");// Also panics with error: 'CapacityError: insufficient capacity'
Perhaps the fix is as simple as capping the precision when doing the rescale? i.e.:
I also noted that the return type of round_sf_with_strategy is Option<Decimal>, and the docs say: "If the resulting number is unable to be represented by the Decimal number then None will be returned.". However, all code paths currently return Some.