36 lines
933 B
Text
36 lines
933 B
Text
Procedure using_Float()
|
|
Define iter.i = 0
|
|
Define.f phi0 = 1.0, phi1, diff
|
|
Repeat
|
|
phi1 = 1.0 + (1.0 / phi0)
|
|
diff = Abs(phi1 - phi0)
|
|
phi0 = phi1
|
|
iter + 1
|
|
Until (1.0e-5 > diff)
|
|
|
|
PrintN("Using type Float --")
|
|
PrintN("Result: " + FormatNumber((phi1), 10) + " after " + Str(iter) + " iterations")
|
|
PrintN("The error is approximately " + FormatNumber((phi1 - (0.5 * (1.0 + Sqr(5.0)))), 10))
|
|
EndProcedure
|
|
|
|
Procedure using_Double()
|
|
Define iter.i = 0
|
|
Define.d phi0 = 1.0, phi1, diff
|
|
Repeat
|
|
phi1 = 1.0 + (1.0 / phi0)
|
|
diff = Abs(phi1 - phi0)
|
|
phi0 = phi1
|
|
iter + 1
|
|
Until (1.0e-5 > diff)
|
|
|
|
PrintN("Using type Double --")
|
|
PrintN("Result: " + FormatNumber((phi1), 10) + " after " + Str(iter) + " iterations")
|
|
PrintN("The error is approximately " + FormatNumber((phi1 - (0.5 * (1.0 + Sqr(5.0)))), 10))
|
|
EndProcedure
|
|
|
|
OpenConsole()
|
|
using_Float()
|
|
PrintN("")
|
|
using_Double()
|
|
Input()
|
|
CloseConsole()
|