Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Help with 2 functions


I need a function that can calculate decimal number n of pi. (for example n=1 gives 1 n=2 gives 4 ... (pi=3.1415....)


Can someone help me out?




0
hulken
Asked:
hulken
1 Solution
 
Lee_NoverCommented:
a very simple thing would be :

procedure TForm1.Button3Click(Sender: TObject);
var tmpStr: string;
begin
     tmpStr:=Format('%.16f', [Pi]);
     Delete(tmpStr, 1, 2);
     Caption:=tmpStr;
     Edit2.Text:=tmpStr[StrToIntDef(Edit1.Text, 1)];
end;


where Edit1.Text holds the decimal wich we want

:)
0
 
Lee_NoverCommented:
btw .. whats the second function ? :)))
0
 
robert_marquardtCommented:
I have a simple C program at home which gives 4 digits of Pi on each iteration. I will have a look if it still exists.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
hulkenAuthor Commented:
Sorry  I think I was not clear here.

About the "Two functions" I changed my mind so I just need one... forgot to change the subject.

About your Answer Lee.

This does not calculate pi. Try to calculate the decimal number 1000 :-) with your example.

I need a mor correct solution that should be general.

Ii migt be possible to use some of the formulas number
76-8 on
http://mathworld.wolfram.com/PiFormulas.html


0
 
Lee_NoverCommented:
aaahhh ok :)
0
 
Lee_NoverCommented:
uhhh too late
and I just spent the whole night translating and optimizing some code I barely understood :)
ah well .. :)
0
 
hulkenAuthor Commented:
Lee Nover.  I love things like this so if you share the code with me I will add some points for you.

One thing that I think would be nice is if it is possible to somhow save the current run (to a file) to be able to start over without restarting from the beginning.

Another nice thing that I don't know how to do is to take time of the current run so I know which method that is the fastgest.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now