Difference between revisions of "83Plus:Basic:Routines:DecToFrac"
From WikiTI
Calc84maniac (Talk | contribs) (Added my smaller routine) |
m (forgot an "End" in my slower, larger routine) |
||
Line 25: | Line 25: | ||
L1(Ans)L1(Ans-1)→L1(Ans-1 ;multiply the last two elements of L1 together | L1(Ans)L1(Ans-1)→L1(Ans-1 ;multiply the last two elements of L1 together | ||
End | End | ||
− | + | End | |
;L1(1)=numerator, L1(2)=denominator</nowiki> | ;L1(1)=numerator, L1(2)=denominator</nowiki> | ||
Latest revision as of 05:40, 11 April 2007
Saibot84's routine:
code ;comment ;K can be any real value 1≠round(fPart(K),9 ;check for calc thinking the fractional part=1 K(Ans)+not(Ans)(1+int(K ;if fPart=1, then Ans=int(K)+1, else, Ans=K {Ans,1→L1 ;L1={numerator,denominator If fPart(L1(1 ;if there's a fPart to the numerator... Then {K→L1 ;leave just the numerator in L1 For(C,0,1 ;initiate a loop If 1=round(fPart(L1(dim(L1))),9 ;if the fPart of the last element of L1=1... 1+int(L1(dim(L1→L1(dim(L1 ;the last element of L1=int(last element of L1)+1 augment(L1,{fPart(L1(dim(L1)))^(-1 ;append the inverse of the fPart(last element of L1) to L1 0→C ;force the For loop to repeat upon next End If L1(dim(L1))=int(round(L1(dim(L1)),9 ;if the last element of L1 is an interger... 1→C ;we do NOT want to repeat the loop End ;to loop or not to loop, that is the question For(C,0,dim(L1)-2 ;for each element of L1, except one... dim(L1)-C ;saving memory and preparing to do the work L1(Ans)L1(Ans-1)→L1(Ans-1 ;multiply the last two elements of L1 together End End ;L1(1)=numerator, L1(2)=denominator
calc84maniac's routine:
:{Ans,1,fpart(abs(Ans :While [e]-9<Ans(3 ;[e] is little scientific notation e :{Ans(1),Ans(3),Ans(3)fpart(Ans(2)/Ans(3 :End :round({Ans(1),1}/Ans(2),0