use super::funejson::Value; use super::math_rational_rational::{rational, rational_from_value}; use super::math_round_div::round_div; /// The integer a fraction rounds to, under an explicit rounding mode: the /// point where an exact rate becomes minor units, so the policy is the /// caller's to state. /// /// # Panics /// Panics on a zero denominator, a part outside ±(2^53 - 1), or an unknown mode. pub fn rational_to_integer(r: &Rational, mode: &str) -> i64 { let n = rational(r.numerator, r.denominator); round_div(n.numerator, n.denominator, mode) } pub fn fune_vector(args: &[Value]) -> Value { Value::Int(rational_to_integer(&rational_from_value(&args[0]), args[1].as_str())) }