25 lines
612 B
Plaintext
25 lines
612 B
Plaintext
Procedure.i ggT(a.i, b.i)
|
|
Define t.i : If a < b : Swap a, b : EndIf
|
|
While a%b : t=a : a=b : b=t%a : Wend : ProcedureReturn b
|
|
EndProcedure
|
|
|
|
Procedure.s Dec2Rat(dn.d)
|
|
Define nk$, gt.i, res$
|
|
nk$=Trim(StringField(StrD(dn),2,"."),"0")
|
|
gt=ggT(Val(nk$),Int(Pow(10.0,Len(nk$))))
|
|
res$=Str(Val(nk$)/gt)+"/"+Str(Int(Pow(10.0,Len(nk$)))/gt)
|
|
ProcedureReturn res$
|
|
EndProcedure
|
|
|
|
OpenConsole()
|
|
Define d.d
|
|
Repeat
|
|
Read.d d : If Not (d>0.0 And d<1.0) : Break : EndIf
|
|
Print(LSet(StrD(d),15," ")+" -> "+#TAB$+Dec2Rat(d)+#CRLF$)
|
|
ForEver
|
|
Input() : End
|
|
|
|
DataSection
|
|
Data.d 0.9054054,0.518518,0.75,0.0
|
|
EndDataSection
|