BBS: Inland Empire Archive Date: 05-24-92 (11:09) Number: 191 From: ROB FLOR Refer#: NONE To: BILL WHITE Recvd: NO Subj: Programming Pi Conf: (2) Quik_Bas
BW>RF> I just saw this post by accident, don't know why I didn't get >RF>it last week. Did you see my subsequent post using integers and >RF>postponing the division until the end? BW> No, didn't see it. I find a lot goes unseen - I'll >find others responding to messages I never the original >of - the system isn't perfect. And, of course, I'll have >to admit that sometimes I zip thru pretty quickly, >especially when there's been a 2 day dry period followed >by 250 messages! You are very lucky. We get 40 - 50 a day this side of the black hole. Here it is. '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= DEFINT A-Z :DEFLNG A,B,C,D A = 1: B = 1: C = 1: Sign = 0 N = 25 'lets say FOR D = 3 TO N STEP 2 Sign = NOT Sign 'Find common denominator, A*D/B*D, C*B/D*B IF Sign THEN C = -B ELSE C = B 'C is always 1 so 1*B=B B = B * D 'D*B = B*D so skip calculating D*B A = A * D 'multiply top and bottom by same amount A = A + C ' A = A + [+|-]C 'faster ' PRINT "Intermediate calculation of pi = 4( "; A; "/"; B; " )" 'slower PRINT "PI="; 4# * (A / B) NEXT PRINT "pi to "; N; " calculations ="; 4# * (A / B) 'the only division '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ' Rob * OLX 2.2 * * IMAGE OF ELVIS IN DUST BUNNY * pine cone diet page 8 --- WM v2.01/91-0156 * Origin: BEAR HEAVEN BBS (914) 677-6948 MILLBROOK NY (1:272/53)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET