Solved

Help with 2 functions

Posted on 2002-06-04
8
137 Views
Last Modified: 2010-04-04

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
Comment
Question by:hulken
8 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7053472
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7053556
btw .. whats the second function ? :)))
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7053607
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
 

Author Comment

by:hulken
ID: 7053660
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
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!

 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7053699
aaahhh ok :)
0
 
LVL 45

Accepted Solution

by:
aikimark earned 200 total points
ID: 7053737
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7059435
uhhh too late
and I just spent the whole night translating and optimizing some code I barely understood :)
ah well .. :)
0
 

Author Comment

by:hulken
ID: 7059815
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

Featured Post

Highfive Gives IT Their Time Back

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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