pub fn value_to_steps_nearest(
value: Decimal,
step: Decimal,
) -> Result<i64, PrecisionError>Expand description
Converts a value to a whole number of steps, rounding to the nearest step (halves go away from zero).
§Errors
PrecisionError::InvalidStep for a step that is zero or negative,
PrecisionError::StepsOverflow if the count does not fit in an i64.
§Examples
use brokapi_bcs_protocol::utils::precision::value_to_steps_nearest;
use rust_decimal::Decimal;
assert_eq!(value_to_steps_nearest(Decimal::new(10105, 2), Decimal::new(5, 2))?, 2021);