add from and to raw

This commit is contained in:
Corwin Kuiper 2021-06-05 17:40:41 +01:00
parent e2925eb917
commit e55ef4d152

View file

@ -131,6 +131,14 @@ impl<const N: usize> Num<N> {
Num(i32::MIN) Num(i32::MIN)
} }
pub fn from_raw(n: i32) -> Self {
Num(n)
}
pub fn to_raw(&self) -> i32 {
self.0
}
pub fn int(&self) -> i32 { pub 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;