Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Pi number In C++ Please HELPPPP!!!!!!!!!

Reply
Thread Tools

Pi number In C++ Please HELPPPP!!!!!!!!!

 
 
FSMehmet
Guest
Posts: n/a
 
      02-16-2009
Hi how are you???
Hey who can help me to find the 111 digit of pi number in C++
Pleaseeee helpppppppppp.
 
Reply With Quote
 
 
 
 
Fred
Guest
Posts: n/a
 
      02-16-2009
On Feb 16, 11:14*am, FSMehmet <(E-Mail Removed)> wrote:
> Hi how are you???
> Hey who can help me to find the 111 digit of pi number in C++
> Pleaseeee helpppppppppp.


"1"

--
Fred
 
Reply With Quote
 
 
 
 
red floyd
Guest
Posts: n/a
 
      02-16-2009
FSMehmet wrote:
> Hi how are you???
> Hey who can help me to find the 111 digit of pi number in C++
> Pleaseeee helpppppppppp.


Ask your instructor.
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      02-16-2009
"FSMehmet" wrote:

> Hey who can help me to find the 111 digit of pi number in C++


There are some nice hits on google if you give it
pi algorithm
as a search target. But since C++ does not deal innately with numbers as
large as 111 digits, you will need some way to attack that problem. What
rules did your instructor give you? Can you use an existing big number
library? Or must you write your own? Break the problem down into sub
problems until you get to something you can actually, or potentially, do. A
four function calculator isn't hard in C++, but the method from the google
hits I favored required square roots too, so that might be next sub problem.
Think Newton-Raphson.


 
Reply With Quote
 
mzdude
Guest
Posts: n/a
 
      02-16-2009
On Feb 16, 2:14*pm, FSMehmet <(E-Mail Removed)> wrote:
> Hi how are you???
> Hey who can help me to find the 111 digit of pi number in C++
> Pleaseeee helpppppppppp.


goto wikipedia and look up pi.

create a small program

const char pi[] = "314159265358979323846264338327950288419716939 "
"937510582097494459230781640628620899862803482 "
"53421170679821480865";

char getPiDigit( int idx )
{
return pi[idx];
}

Of course this doesn't help when the requirements change to
the 112th or greater position.

Wikipedia also lists several good algorithms for calculating pi.

good luck.
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      02-17-2009
On Feb 16, 8:57 pm, "osmium" <(E-Mail Removed)> wrote:
> "FSMehmet" wrote:
> > Hey who can help me to find the 111 digit of pi number in C++


> There are some nice hits on google if you give it
> pi algorithm
> as a search target. But since C++ does not deal innately with numbers as
> large as 111 digits, you will need some way to attack that problem.


Just a nit, but that should read "[...]since most C++
implementations don't support 111 digit numbers[...]". The
standard requires a minimum of 10 decimal digits for double, but
it doesn't set any maximum, so an implementation using 256 byte
doubles would be perfectly conform. Albeit a bit slow for most
uses on most platforms. (FWIW: I am aware of one
implementation of Fortran which used 256 byte floats on a
Siemens BS2000. And yes, it was very, very slow.)

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      02-17-2009
FSMehmet wrote:
> Hi how are you???
> Hey who can help me to find the 111 digit of pi number in C++
> Pleaseeee helpppppppppp.

Start with 3.14159 and work from there

There are plenty of algorithms to find arbitrary number of digits in PI.
I suggest using a search engine to find the algorithms.

If you have a particular question about why your C++ implementation of
said algorithm isn't doing what you expect it to do, then come back and
post.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      02-18-2009
FSMehmet <(E-Mail Removed)> writes:
>Hey who can help me to find the 111 digit of pi number in C++


#include <iostream>
#include <ostream>

int main(){ unsigned long i, j, k, n, p,
q, x, m = 111, len = 370, pi[ 371 ];
for( x = len; x > 0; --x )pi[ x ]= 2;
::std::cout << "3."; n = 0; p = 0;
for( j = 0; j <= m; ++j )
{ q = 0; for( i = len; i > 0; --i )
{ x = 10 * pi[ i ]+ q * i;
pi[ i ]= x %( 2 * i - 1 );
q = x /( 2 * i - 1 ); }
pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
else if( q == 10 ) { putchar( '1' + p );
for( ; n; --n )::std::cout << '0'; p = 0; }
else { if( j > 1 )::std::cout << p;
for( ; n; --n )::std::cout << '9'; p = q; }}
::std::cout << p << '\n'; }

 
Reply With Quote
 
r.isfendiyar@gmail.com
Guest
Posts: n/a
 
      02-18-2009
On 18 Feb, 01:26, (E-Mail Removed)-berlin.de (Stefan Ram) wrote:
> FSMehmet <(E-Mail Removed)> writes:
> >Hey who can help me to find the 111 digit ofpinumber in C++

>
> #include <iostream>
> #include <ostream>
>
> int main(){ unsigned long i, j, k, n, p,
> * q, x, m = 111, len = 370,pi[ 371 ];
> * for( x = len; x > 0; --x )pi[ x ]= 2;
> * ::std::cout << "3."; n = 0; p = 0;
> * for( j = 0; j <= m; ++j )
> * { q = 0; for( i = len; i > 0; --i )
> * * { x = 10 *pi[ i ]+ q * i;
> * * *pi[ i ]= x %( 2 * i - 1 );
> * * * q = x /( 2 * i - 1 ); }
> * *pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
> * * else if( q == 10 ) { putchar( '1' + p );
> * * * for( ; n; --n )::std::cout << '0'; p = 0; }
> * * else { if( j > 1 )::std::cout << p;
> * * * for( ; n; --n )::std::cout << '9'; p = q; }}
> * ::std::cout << p << '\n'; }


Thanksssss .. . . . . .
 
Reply With Quote
 
havocjoseph
Guest
Posts: n/a
 
      02-18-2009
On Feb 17, 8:26*pm, (E-Mail Removed)-berlin.de (Stefan Ram) wrote:
> FSMehmet <(E-Mail Removed)> writes:
> >Hey who can help me to find the 111 digit of pi number in C++

>
> #include <iostream>
> #include <ostream>
>
> int main(){ unsigned long i, j, k, n, p,
> * q, x, m = 111, len = 370, pi[ 371 ];
> * for( x = len; x > 0; --x )pi[ x ]= 2;
> * ::std::cout << "3."; n = 0; p = 0;
> * for( j = 0; j <= m; ++j )
> * { q = 0; for( i = len; i > 0; --i )
> * * { x = 10 * pi[ i ]+ q * i;
> * * * pi[ i ]= x %( 2 * i - 1 );
> * * * q = x /( 2 * i - 1 ); }
> * * pi[ 1 ]= q % 10; q = q / 10; if( q == 9 )++n;
> * * else if( q == 10 ) { putchar( '1' + p );
> * * * for( ; n; --n )::std::cout << '0'; p = 0; }
> * * else { if( j > 1 )::std::cout << p;
> * * * for( ; n; --n )::std::cout << '9'; p = q; }}
> * ::std::cout << p << '\n'; }


Readability fail.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please respond with reasonable answers. [Laptop has a unique identifying code number -- what is this number called?] Radium Computer Support 9 07-01-2007 11:22 AM
OT: Number Nine, Number Nine, Number Nine Frisbee® MCSE 37 09-26-2005 04:06 PM
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments