Approximation using rational operation

If an approximation method uses only the four operations, then it can be done on the rational operation mode of Decimal BASIC. Calculation in the rational operation mode does not have any error.
If you use PRINT USING, calculation results can be expressed as decimal fractions. In that case, the precision is about 1000 digits.

Example. Napier's constant

100 OPTION ARITHMETIC RATIONAL
110 LET format$="#." & REPEAT$("#",999)
120 LET e=1
130 LET f=1
140 FOR i=1 TO 500
150    LET f=f*i
160    LET e=e+1/f
170    PRINT USING format$: e
180 NEXT i
190 END


Back