|
Pi Calculation
|
|
09-07-2009, 05:13 AM
(This post was last modified: 03-05-2010 06:34 AM by drdebcol.)
Post: #1
|
|||
|
|||
|
Pi Calculation
Few years ago i have seen a man who calculated pi on few million decimals.
I thought how smart is he, but he used a formula. Name of that formula is "Gottfried Leibniz formula for pi" and it looks like this : So this is an ordinary series of odd numbers with signed/unsigned change ! So i made an algorithm for pi calculation in which you enter length of series and it calculates. The bigger number you enter pi will be more accurate, but calculation is going to be slower. This calculates pi on 9 decimals, you can easily change in code to bigger number. I am still working on algorithm in C++ for that program with millions of decimals (That is big numbers task like the one with factorials). So here is the code in Pascal : Code: program pi_calculation;Code: # include <iostream>There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
09-07-2009, 07:22 AM
Post: #2
|
|||
|
|||
|
RE: Pi Calculation
It'll be interesting to see your answer, the one with millions of digits. I want see how your going to handle the situations like 4/3 which works out to a repeating decimal 1.3333333.
I have an idea but I'd have to check the bignum library to see if its supported...Good luck..G4143 |
|||
|
09-07-2009, 04:26 PM
Post: #3
|
|||
|
|||
|
RE: Pi Calculation
Well i was thinking about storing in arrays, but it has to be in blocks so it is going to be a bit difficult !
There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
10-27-2009, 08:30 PM
(This post was last modified: 10-27-2009 08:31 PM by Alireza_M.)
Post: #4
|
|||
|
|||
RE: Pi Calculation
(09-07-2009 04:26 PM)drdebcol Wrote: Well i was thinking about storing in arrays, but it has to be in blocks so it is going to be a bit difficult !Hi.You have submitted 10 numbers in the answer for the pascal program.Is that a true limitation?i mean maybe the user wants pi with 15 numbers after point.for example if the answer is : 3.141592653589 compiler will round the last 3 numbers.whats the solution?whats the best answer for the blanks?writeln(n: ( ): ( ) ) Gholamreza Takhti who was he? find out |
|||
|
10-28-2009, 12:28 AM
Post: #5
|
|||
|
|||
|
RE: Pi Calculation
Well, you can put whatever you want there. It is not the problem after all. This is just an example. Bad thing at this program is that it is using standard "real" type and that is not common for huge calculations, but it is good for example.
This is mix of mathematical and programming task. There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|





