mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
make all const functions
This commit is contained in:
parent
e55ef4d152
commit
93b0b757bd
1 changed files with 6 additions and 6 deletions
|
@ -123,23 +123,23 @@ impl<const N: usize> Neg for Num<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const N: usize> Num<N> {
|
impl<const N: usize> Num<N> {
|
||||||
pub fn max() -> Self {
|
pub const fn max() -> Self {
|
||||||
Num(i32::MAX)
|
Num(i32::MAX)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn min() -> Self {
|
pub const fn min() -> Self {
|
||||||
Num(i32::MIN)
|
Num(i32::MIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_raw(n: i32) -> Self {
|
pub const fn from_raw(n: i32) -> Self {
|
||||||
Num(n)
|
Num(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_raw(&self) -> i32 {
|
pub const fn to_raw(&self) -> i32 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn int(&self) -> i32 {
|
pub const fn int(&self) -> i32 {
|
||||||
let fractional_part = self.0 & ((1 << N) - 1);
|
let fractional_part = self.0 & ((1 << N) - 1);
|
||||||
let self_as_int = self.0 >> N;
|
let self_as_int = self.0 >> N;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ impl<const N: usize> Num<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(integral: i32) -> Self {
|
pub const fn new(integral: i32) -> Self {
|
||||||
Self(integral << N)
|
Self(integral << N)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue