pub fn decimal_to_f64_with_validation(
decimal_value: Decimal,
tolerance: f64,
) -> (f64, PrecisionValidation)Expand description
Convert Decimal to f64 with precision validation
This function performs the conversion and returns both the f64 value and the precision validation result. Use this when you need to know about precision loss.
§Arguments
decimal_value- The Decimal value to converttolerance- Acceptable relative error for precision validation
§Returns
A tuple of (f64_value, precision_validation)
§Example
use rust_decimal_macros::dec;
use rusty_common::decimal_utils::{decimal_to_f64_with_validation, PrecisionValidation};
let price = dec!(123.45);
let (f64_price, validation) = decimal_to_f64_with_validation(price, 1e-15);
assert_eq!(f64_price, 123.45);
assert_eq!(validation, PrecisionValidation::Lossless);