»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 06-26-2003, 12:51 PM   #1 (permalink)
Registered User
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,326
korgul is on a distinguished road
more integer spaces

I am trying to determine the value of Pi, just for the heck of it. The problem I am running into is the number of spaces that I can use.
Code:
dim answer
answer = 22 / 7
msgbox (answer)
I tried writing it to a txt file but still get limited by a set amount of spaces. Is there a way to tell it to use X amout of spaces for the answer.

Here is what I have for writing to the txt file
Code:
dim answer

Function WriteLineToFile
   Const ForReading = 1, ForWriting = 2
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\my documents\scripts\testfile.txt", ForWriting, True)
   f.WriteLine answer
   Set f = fso.OpenTextFile("c:\my documents\scripts\testfile.txt", ForReading)
   WriteLineToFile = f.ReadAll
End Function

answer = 22 / 7
writelinetofile
any ideas on how I can do this?

korgul is offline   Reply With Quote
Old 06-26-2003, 10:40 PM   #2 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
sure,

make a circle, measure the area.

determine PI.

a=PI*r**2.

OR

PI=a/r**2???
qball is offline   Reply With Quote
Old 06-27-2003, 03:59 PM   #3 (permalink)
Registered User
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,326
korgul is on a distinguished road
qball

what I am trying to do is have the above script run and determine Pi to the 100th place value.

When I run the script I get this for an answer

3.14285714285714

It repeats which we all know is not supposed to happen with Pi.
korgul is offline   Reply With Quote
Old 06-27-2003, 04:22 PM   #4 (permalink)
Registered User
 
howste's Avatar
 
Join Date: Oct 2001
Location: West Haven, Utah
Posts: 2,063
howste is on a distinguished road
That doesn't look right. Pi isn't 22/7, that's just an approximation.

This is pi (ok, just the beginning of pi): 3.14159265358979

But I don't know how to answer your question about getting it to display (or write to a file) to the 100th decimal.
howste is offline   Reply With Quote
Old 06-27-2003, 10:45 PM   #5 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
Quote:
what I am trying to do is have the above script run and determine Pi to the 100th place value.
how do you think they built the pyramids?

oops, that was easier.

to determine any number to any degree, one must have place to put?

so you need 101+ memory locations? store each value, right?

pi has been defined to the nth degree.

think of it this way, or not.

9999999999999999999999999999999999999999999999999

is a huge number.

9999999999999999999999999999999999999999999999999

is a small string.
qball is offline   Reply With Quote
Old 06-28-2003, 09:58 AM   #6 (permalink)
Registered User
 
nukes's Avatar
 
Join Date: Oct 2002
Location: Scotland, UK
Posts: 2,946
nukes is on a distinguished road
Send a message via AIM to nukes Send a message via Yahoo to nukes
Pi is normally calculated by means of a series (normally the Chudnovskys brothers' method - can't remember how to spell it)
You need to watch out for rounding errors, and I would advise you to look hard at your floating-point handling code. The standard library functions aren't good enough for this, so do some research into fp arithmatic in binary form and how the computer works with it.
Code:
double calculate_pi(int terms) {
double calcpi = x =0;
for(i==n: i = 0:i++)
x = 4 * (-1) ^ i / (2 * i + 1);
calcpi += x ;
return calcpi; }
As you can see, this is constructed from a series. It is dependant on the number of terms to what accuracy. If you are indeed just using double, then you may want to truncate the number at each term to avoid rounding errors.
__________________
_____
NuKeS
nukes is offline   Reply With Quote
Old 06-28-2003, 09:58 PM   #7 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
Quote:
Pi is normally calculated by means of...
so, nobody tried?

"make a circle, measure the area."
qball is offline   Reply With Quote
Old 06-28-2003, 10:29 PM   #8 (permalink)
Registered User
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,326
korgul is on a distinguished road
It seems that everyone is stuck on Pi.

It can be any number I just need to know how to make more places for the numbers.

If I have any division problem that when calculated needs the answer to be to the 23 place value. How do I add those places values with out the script rounding off till then.

I only used Pi because that is one that I know will reach way out there, as far a digits.

So I am not so much worried about how to figure out Pi, but am more interested in finding out how to have an answer have an unlimited amount of digits.
korgul is offline   Reply With Quote
Old 06-28-2003, 10:36 PM   #9 (permalink)
Registered User
 
Gait_Keeper's Avatar
 
Join Date: Feb 2003
Location: Da Bronx, NY
Posts: 1,709
Gait_Keeper is on a distinguished road
Send a message via AIM to Gait_Keeper
http://www.exploratorium.edu/learning_studio/pi/

http://www.angio.net/pi/piquery
Gait_Keeper is offline   Reply With Quote
Old 06-29-2003, 07:53 PM   #10 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
qball is on a distinguished road
Gait_Keeper,

whoa! awesome links.

korgul,

good enough answer.

The only time I had to calc PI was only a simple programming exercise to 7/8/9 digits.

I have to believe most calcs of PI will ultimately store result in some sort of string var(maybe more than one var). as in:

String result = "":
//code to calc PI 1 digit at a time.
result += digit;
//test result not getting bigger than string, if bigger, use a string array
print result;
qball is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 04:20 AM.