(続)Rubyのテストデモ

Rubyによるテストの続きです。

下記のファイルがテストファイルです。
%vi test12.rb
require 'rational'
a = Rational(1, 10)
b = Rational(9, 1)
i = 1
c = Rational(0, 1)
d = Rational(1, 1)
while i < 20 do
c = c + b * a * d
stringoutput = sprintf("%18.16f %a(%a)", c, c, eval("0." + "9" * i))
print i," ", c," ",stringoutput,"\n"
i += 1
d *= a
end

結果です。興味深いです。