mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Fix int() method to return as-if this was a float
This commit is contained in:
parent
8b1ad400a7
commit
56cf16def4
|
@ -132,7 +132,14 @@ impl<const N: usize> Num<N> {
|
|||
}
|
||||
|
||||
pub fn int(&self) -> i32 {
|
||||
self.0 >> N
|
||||
let fractional_part = self.0 & ((1 << N) - 1);
|
||||
let self_as_int = self.0 >> N;
|
||||
|
||||
if self_as_int < 0 && fractional_part != 0 {
|
||||
self_as_int + 1
|
||||
} else {
|
||||
self_as_int
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(integral: i32) -> Self {
|
||||
|
|
Loading…
Reference in a new issue