Solved

Calculate Value of Pi

Posted on 2006-11-14
3
908 Views
Last Modified: 2008-02-01
I remeber a LONG time ago (1981-1982), coming across a BASIC program that would calculate the value of Pi to a specific number of decimal places. It stored each 'digit' in an array element and then when the calculation was complete, just concatenated all of the digits. It was limited by memory size (how large you could dimension the array).

I know the need for a value of Pi to any more than 5 or 6 decimal places is probably overkill unless you are trying to aim a rocket at a star a few million light years from earth, but I recall it was kind of fun to have a sheet of paper filled with digits and telling everyone it was Pi to 1,200 decimal places (or whatever it was-back in the days of 64K RAM you were kind of limited).

Does anyone have a similar VB program laying around just gathering dust? As I recall, with my old system (it was even before the days of the IBM PC), it took almost 3 days to calculate Pi to whatever the limit was (as I recall, it was around 1,200 decimal places).

Doug
0
Comment
Question by:dbbishop
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17941259
0
 
LVL 15

Author Comment

by:dbbishop
ID: 17944855
These are 'okay' but give a limited value of Pi. Using Atn() or a series limits the value to can return to the number of digits supported by the number type you use within your OS. The neat thing about the iteration I recall is that, as I stated, each digit was stored in an element of a string array and after calculating 1000 elements, you just concatenated all the elements together. I believe you started out with 3.14 and went from there. So whatever the calucation was, at the end you ran code similar to:

Print "3.14";
For i = 0 to UBound(a)
    Print a(i);
Next i
Print

Each element in a() was just a single digit. As I recall, the program used a couple of nested For...Next loops and was written in BASIC. Anyone out there with fond memories of such a program?
0
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 125 total points
ID: 17945003
Found this:

http://www.po28.dial.pipex.com/maths/software.htm

About half way down the page is VB source code to do what you want.

Kevin
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now