luaur_vm/functions/roundodd.rs
1use crate::functions::mul_128::mul_128;
2
3#[inline]
4pub fn roundodd(ghi: u64, glo: u64, cp: u64) -> u64 {
5 let mut xhi: u64 = 0;
6 let _xlo = mul_128(glo, cp, &mut xhi);
7
8 let mut yhi: u64 = 0;
9 let ylo = mul_128(ghi, cp, &mut yhi);
10
11 let z = ylo.wrapping_add(xhi);
12 let carry = if z < xhi { 1 } else { 0 };
13 let bit = if z > 1 { 1 } else { 0 };
14
15 yhi.wrapping_add(carry) | bit
16}