mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
use easily optimisable division for truncate
This commit is contained in:
parent
eb212e7f91
commit
900b594039
|
@ -222,14 +222,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Num<I, N> {
|
|||
}
|
||||
|
||||
pub fn trunc(&self) -> I {
|
||||
let fractional_part = self.0 & ((I::one() << N) - I::one());
|
||||
let self_as_int = self.0 >> N;
|
||||
|
||||
if self_as_int < I::zero() && fractional_part != I::zero() {
|
||||
self_as_int + I::one()
|
||||
} else {
|
||||
self_as_int
|
||||
}
|
||||
self.0 / (I::one() << N)
|
||||
}
|
||||
|
||||
pub fn rem_euclid(&self, rhs: Self) -> Self {
|
||||
|
|
Loading…
Reference in a new issue