'=========================================================================== ' Subject: Calculating Pi Date: 06-14-03 ( : ) ' Author: Rick Clark Code: ATOM ' Origin: rickclark58@yahoo.com Packet: ATOM.ABC '=========================================================================== # This code uses Gregory's series # (pi/4 = 1-1/3+1/5-1/7+...) # to calculate the value of Pi. cls: print: "3.14159265358979323846" set: I1, 1 # denominator set: I2, 1000 # update counter set: I3, 1 # sign set: I4, 1 # const, numerator set: I5, -1 # const, used to flip sign set: I6, 4 # const, pi multiplier set: I7, 0 # const set: F1, 0 # sum set: F2, 0 # temp # sum = sum + sign * 1 / denominator AGAIN@ div: F2, I4, I1 mul: F2, I3, F2 add: F1, F2, F1 # flip sign mul: I3, I5, I3 # must skip even values inc: I1, 2 dec: I2 eq: I2, I7, UPDATE, AGAIN UPDATE@ set: I2, 1000 # calc and print current sum mul: F2, I6, F1 locate: 2, 1 print: F2 goto: AGAIN