This commit is contained in:
2024-08-06 18:10:48 -04:00
parent 951c95d13f
commit 2b7e635037
2 changed files with 30 additions and 5 deletions

View File

@@ -21,6 +21,9 @@ impl FiNum {
pub fn zero() -> Self {
FiNum(0u64)
}
pub fn one() -> Self {
FiNum(1u64<<32)
}
pub fn is_zero(self) -> bool {
self.0==0
}
@@ -30,6 +33,10 @@ impl FiNum {
pub fn recip(&self) -> Self {
FiNum((0x8000000000000000u64/self.0)<<1)
}
pub fn fmt_recip(&self) -> String {
if *self<FiNum::one() { format!("1/{}",self.recip()) }
else { format!("{}",self) }
}
pub fn serialize(&self) -> String {
format!("{:X}",self.0)
}