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++

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++

"1"

--
Fred

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++

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.

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++

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.

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

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++

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/>

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'; }

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 .. . . . . .

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'; }