mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
make 16 bit precision work
This commit is contained in:
parent
71e680f365
commit
09331d1cb5
|
@ -133,7 +133,7 @@ macro_rules! upcast_multiply_impl {
|
|||
.wrapping_mul(b_frac)
|
||||
.wrapping_add(b_floor.wrapping_mul(a_frac)),
|
||||
)
|
||||
.wrapping_add(a_frac.wrapping_mul(b_frac) >> n)
|
||||
.wrapping_add(((a_frac as u32).wrapping_mul(b_frac as u32) >> n) as $T)
|
||||
}
|
||||
};
|
||||
($T: ty, $Upcast: ty) => {
|
||||
|
@ -1236,6 +1236,17 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_16_bit_precision_i32() {
|
||||
let a: Num<i32, 16> = num!(1.923);
|
||||
let b = num!(2.723);
|
||||
|
||||
assert_eq!(
|
||||
a * b,
|
||||
Num::from_raw(((a.to_raw() as i64 * b.to_raw() as i64) >> 16) as i32)
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_numbers() {
|
||||
// test addition
|
||||
|
|
Loading…
Reference in a new issue