don't mess with casts, wtf

This commit is contained in:
Quaternions 2023-12-02 01:31:42 -08:00
parent 49e077996d
commit 1790390055

View File

@ -105,23 +105,23 @@ impl Ratio64{
None None
}else{ }else{
let d=gcd(num.unsigned_abs(),den); let d=gcd(num.unsigned_abs(),den);
Some(Self{num:num/d as i64,den:den/d}) Some(Self{num:num/(d as i64),den:den/d})
} }
} }
#[inline] #[inline]
pub fn mul_int(&self,rhs:i64)->i64{ pub fn mul_int(&self,rhs:i64)->i64{
rhs*self.num/self.den as i64 rhs*self.num/(self.den as i64)
} }
#[inline] #[inline]
pub fn rhs_div_int(&self,rhs:i64)->i64{ pub fn rhs_div_int(&self,rhs:i64)->i64{
rhs*self.den as i64/self.num rhs*(self.den as i64)/self.num
} }
#[inline] #[inline]
pub fn mul_ref(&self,rhs:&Ratio64)->Ratio64{ pub fn mul_ref(&self,rhs:&Ratio64)->Ratio64{
let (num,den)=(self.num*rhs.num,self.den*rhs.den); let (num,den)=(self.num*rhs.num,self.den*rhs.den);
let d=gcd(num.unsigned_abs(),den); let d=gcd(num.unsigned_abs(),den);
Self{ Self{
num:num/d as i64, num:num/(d as i64),
den:den/d, den:den/d,
} }
} }
@ -234,7 +234,7 @@ impl std::ops::Mul<Ratio64> for Ratio64{
let (num,den)=(self.num*rhs.num,self.den*rhs.den); let (num,den)=(self.num*rhs.num,self.den*rhs.den);
let d=gcd(num.unsigned_abs(),den); let d=gcd(num.unsigned_abs(),den);
Self{ Self{
num:num/d as i64, num:num/(d as i64),
den:den/d, den:den/d,
} }
} }
@ -451,7 +451,7 @@ impl Into<f32> for Planar64{
impl From<Ratio64> for Planar64{ impl From<Ratio64> for Planar64{
#[inline] #[inline]
fn from(ratio:Ratio64)->Self{ fn from(ratio:Ratio64)->Self{
Self((((ratio.num as i128)<<32)/ratio.den as i128) as i64) Self((((ratio.num as i128)<<32)/(ratio.den as i128)) as i64)
} }
} }
#[derive(Debug)] #[derive(Debug)]
@ -572,7 +572,7 @@ impl std::ops::Div<Planar64> for Planar64{
type Output=Planar64; type Output=Planar64;
#[inline] #[inline]
fn div(self, rhs: Planar64) -> Self::Output { fn div(self, rhs: Planar64) -> Self::Output {
Planar64((((self.0 as i128)<<32)/rhs.0 as i128) as i64) Planar64((((self.0 as i128)<<32)/(rhs.0 as i128)) as i64)
} }
} }
// impl PartialOrd<i64> for Planar64{ // impl PartialOrd<i64> for Planar64{