-
Notifications
You must be signed in to change notification settings - Fork 148
High precision math with decimal datatype
This example
shows how to generate the "golden ratio" to 28 digits of precision using the decimal datatype and a Fibonacci Sequence generator function
.
// shows use of infinite fibonacci sequence with decimal datatype to generate golden ratio to 28 digits
def fib(): a as decimal = 0; b as decimal = 1 while true: yield b a, b = b, a + b
i = 0
diff as decimal = 10.0**-28
lastf as decimal = 1
ratio as decimal = 0
for f in fib():
// print "$i
print "error factor less than
Output:
error factor less than 0.0000000000000000000000000001 on 72th iteration golden ratio = 1.6180339887498948482045868344