home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

more integer spaces

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2626
Discussions: 200,999, Posts: 2,379,998, Members: 246,368
Old June 26th, 2003, 03:51 PM   Digg it!   #1 (permalink)
Ultimate Member
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,569
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 June 27th, 2003, 01:40 AM     #2 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
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 June 27th, 2003, 06:59 PM     #3 (permalink)
Ultimate Member
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,569
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 June 27th, 2003, 07:22 PM     #4 (permalink)
Thaumaturge Member
 
howste's Avatar
 
Join Date: Oct 2001
Location: West Haven, Utah
Posts: 15,330
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 June 28th, 2003, 01:45 AM     #5 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
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 June 28th, 2003, 12:58 PM     #6 (permalink)
Ultimate Member
 
nukes's Avatar
 
Join Date: Oct 2002
Location: Scotland, UK
Posts: 3,221
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 June 29th, 2003, 12:58 AM     #7 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
Quote:
Pi is normally calculated by means of...

so, nobody tried?

"make a circle, measure the area."
qball is offline   Reply With Quote
Old June 29th, 2003, 01:29 AM     #8 (permalink)
Ultimate Member
 
korgul's Avatar
 
Join Date: Oct 2001
Location: York, PA.
Posts: 1,569
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 June 29th, 2003, 01:36 AM     #9 (permalink)
Bringing Da Funk
 
Gait_Keeper's Avatar
 
Join Date: Feb 2003
Location: Da Bronx, NY
Posts: 3,985
Send a message via AIM to Gait_Keeper
Gait_Keeper is offline   Reply With Quote
Old June 29th, 2003, 10:53 PM     #10 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3108)
‘Rogue’ or ‘Rouge’? (8)
Charges against non-tippers dropped.. (22)
Foxconn Blackops x48 MoBo (5)
Nvidia GTX 260 problem (14)
Delete an OS (18)
Laptop with wireless problem. (13)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (9)
windows vista security holes (19)
[F@H SPAM 11/16/09] ! 1/2 months to.. (41)
windows 7 problem (7)
Recent Discussions
add ram to existing (4)
Computer shutting down on its own (6)
EVGA 9800 gtx help with finding a goo.. (13)
"Documents and Settings" fo.. (7)
Delete an OS (18)
Outputing 1080p from my PC to my 720p.. (0)
panasonic dmr ez48veb recorder (0)
Need help getting speakers to work (2)
Nvidia GTX 260 problem (14)
Laptop with wireless problem. (13)
Point and Shoot Camera Suggestions. (9)
Is the PSU I received dead? (16)
FreeAgent drive software not x64 comp.. (1)
Intel 5100 AGN issues fixed yet? (28)
Foxconn Blackops x48 MoBo (5)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (41)
Print spooler problem (17)
Q9650 vs. Q9550 (2)
Desktop Calendar Application (2)
Looking for new motherboard (1)
soundmon.exe (8)
Jedi Academy Problem (3)
Can a page file be "too big".. (1)
Size after cutting 700Mb file is 2.5 .. (0)
windows vista security holes (19)


All times are GMT -4. The time now is 02:02 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28