Solved

Calculate Value of Pi

Posted on 2006-11-14
3
912 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 143

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 59
Change the path of the data source in my Excel pivot table with macro 4 47
using Access 8 75
Error with a code discussed on this page 5 29
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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