lol idk #1

Open
Quaternions wants to merge 826 commits from StrafesNET/strafe-project:master into master
4 changed files with 31 additions and 2 deletions
Showing only changes of commit 276602e5f3 - Show all commits

1
Cargo.lock generated
View File

@ -58,6 +58,7 @@ version = "0.1.0"
dependencies = [
"bnum",
"fixed",
"typenum",
]
[[package]]

1
fixed_wide/Cargo.lock generated
View File

@ -50,6 +50,7 @@ version = "0.1.0"
dependencies = [
"bnum",
"fixed",
"typenum",
]
[[package]]

View File

@ -6,3 +6,4 @@ edition = "2021"
[dependencies]
bnum = "0.11.0"
fixed = "1.28.0"
typenum = "1.17.0"

View File

@ -1,4 +1,30 @@
pub struct Fixed<I,Frac>{
bits:I,
use bnum::types::{I256,I512};
use fixed::{FixedI64,FixedI128};
use typenum::{Sum, Unsigned};
use typenum::consts::{U32,U64,U96,U128,U160,U192,U224,U256};
pub trait WideMul<Rhs=Self>{
type Output;
fn wide_mul(self,rhs:Rhs)->Self::Output;
}
pub struct Fixed<Int,Frac>{
bits:Int,
phantom:std::marker::PhantomData<Frac>,
}
pub type FixedI256<Frac>=Fixed<I256,Frac>;
pub type FixedI512<Frac>=Fixed<I512,Frac>;
impl<A,B> WideMul<FixedI128<B>> for FixedI128<A>
where
A:std::ops::Add<B>,
B:Unsigned,
{
type Output=FixedI256<Sum<A,B>>;
fn wide_mul(self,rhs:FixedI128<B>)->Self::Output{
FixedI256{
bits:I256::from(self.to_bits())*I256::from(rhs.to_bits()),
phantom:std::marker::PhantomData,
}
}
}