5/28/2023 0 Comments Decimal to fraction converterVisual Basic code for this conversion is given belowįunction Decimal2Fraction(ByVal decNum As Double, ByVal accuracy As Double, _ ByRef nominator, ByRef denominator, ByRef remainder) ' Input decNum always between zero to 1 ![]() ![]() , thus we stop the iteration and report the conversion of decimal We use difference equation with initial condition We start with making a continued fraction. We want to get the fraction approximation. The iteration is stop when the absolute error is very smallĪnd we report the result of one iteration before. Once we get the term of continued fraction, we can use the difference equation Then continued the iteration with iteration formula May not have the exact decimal number and we can use approximation of continued fraction using this simple algorithm:Īt the beginning, we compute term, error and reciprocal of remainder respectively as Of course, we can always say that 2.14567 = 214567/100000 without any approximation.
0 Comments
Leave a Reply. |