kill tabs

This commit is contained in:
2026-02-25 08:18:16 -08:00
parent 413e88d1ec
commit 8c5e80d860

View File

@@ -68,15 +68,16 @@ pub fn ratio_from_float(value:f64)->Result<Ratio64,RatioFromFloatError>{
}
let mut p_prev=1i64;
let mut q_prev=0i64;
let mut p_cur=0i64;
let mut q_cur=1i64;
let mut q_prev=0i64;
let mut p_cur=0i64;
let mut q_cur=1i64;
// compute continued fraction
loop{
let whole=in_den/in_num;
if whole==0{
// we have depleted the input fraction and created an exact representation
break;
}
@@ -86,16 +87,18 @@ pub fn ratio_from_float(value:f64)->Result<Ratio64,RatioFromFloatError>{
}
let Some(p_next)=ma(p_prev,p_cur,whole as i64)else{
// overflow
break;
};
let Some(q_next)=ma(q_prev,q_cur,whole as i64)else{
// overflow
break;
};
p_prev=p_cur;
q_prev=q_cur;
p_cur=p_next;
q_cur=q_next;
q_prev=q_cur;
p_cur=p_next;
q_cur=q_next;
(in_num,in_den)=(in_den-in_num*whole,in_num);
}