COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### algorithm for finding Pi in C

• Email
• Follow

Hi all,

see:- http://mathforum.org/library/drmath/view/54456.html

 0
Reply aarklon (253) 5/24/2008 3:53:16 AM

See related articles to this posting

aarklon@gmail.com wrote:
> Hi all,
>
> see:- http://mathforum.org/library/drmath/view/54456.html

This works for me:

#include <float.h>
/*
** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
*/
static double fs_pi(void);

static double fs_pi(void)
{
unsigned n;
double a, b;
static double p;
static int initialized;

if (!initialized) {
initialized = 1;
n = 1;
a = 3;
do {
a /= 9;
b  = a / n;
n += 2;
a /= 9;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 4);
n = 1;
a = 2;
do {
a /= 4;
b  = a / n;
n += 2;
a /= 4;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 2);
p *= 4;
}
return p;
}

--
pete

 0
Reply pfiland (6614) 5/24/2008 6:13:02 AM

aarklon@gmail.com said:

> Hi all,
>
> see:- http://mathforum.org/library/drmath/view/54456.html

Presumably you want Pi? Easy. It's about 3.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/24/2008 6:44:15 AM

On May 24, 2:44=A0pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> aark...@gmail.com said:
>
> > Hi all,
>
> > see:-http://mathforum.org/library/drmath/view/54456.html
>
> Presumably you want Pi? Easy. It's about 3.

So we doan' need no arbitrary "unlimited" "limited only by time and
memory space" precision?

Wouldn't 3.14  be a better answer in all cases? That's what most
"normal geeks" remember from math class.

And isn't usually a #define const?

>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> "Usenet is a strange place" - dmr 29 July 1999


 0
Reply spinoza1111 (3250) 5/24/2008 9:41:43 AM

spinoza1111 said:

> On May 24, 2:44 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> aark...@gmail.com said:
>>
>> > Hi all,
>>
>> > see:-http://mathforum.org/library/drmath/view/54456.html
>>
>> Presumably you want Pi? Easy. It's about 3.
>
> So we doan' need no arbitrary "unlimited" "limited only by time and
> memory space" precision?

It depends. Sometimes we do, and sometimes we don't.

> Wouldn't 3.14  be a better answer in all cases?

No, not in all cases. In some cases, "about 3" is far superior, although
admittedly "just over 3" is even better. Case in point: you're parked by
the lake, looking at a map thereof. Using your thumb against the map scale
indicator and then against the lake, you can see that it's about a mile
across, and roughly circularish. There's a path all the way round. In this
kind of terrain (reasonably flat, for obvious reasons) you can manage,
say, 4mph. Your time, however, is not unlimited. Have you got time to walk
around the lake? In such a situation, taking pi as "three-and-a-bit" is
far more appropriate than the more pernickety 3.14.

Note that, as an estimate of pi, 3 is only about 4.5+% short. That's not

> And isn't usually a #define const?

No (but somehow I get the feeling that either I'm misinterpreting your
question, or you're going to misinterpret my answer, or perhaps both).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/24/2008 10:41:40 AM


> see:- http://mathforum.org/library/drmath/view/54456.html

Wow it gives all the worst ways to calculate pi, and it has nothing specific
to C. Its win-win!


 0
Reply MisterE1 (26) 5/24/2008 11:07:06 AM

pete ha scritto:

> static d

Why all these 'static'?

 0

nembo kid wrote:

> pete ha scritto:
>
>> static d
>
> Why all these 'static'?

That's to prevent the objects from having external linkage, which is
mainly to control namespace pollution. IOW these identifiers are
visible only in this translation unit, from where they are defined
until the end of the unit, so you can reuse these identifiers for other
purposes elsewhere. The default linkage for functions and file scope
objects is external. The static qualifier in these cases suppress this.


 0
Reply santosh.k83 (3969) 5/24/2008 4:52:36 PM

nembo kid wrote:
> pete ha scritto:
>
>> static d
>
> Why all these 'static'?

There is no reason to calculate that one,
more than once.

--
pete

 0
Reply pfiland (6614) 5/24/2008 5:31:02 PM

On Fri, 23 May 2008 20:53:16 -0700 (PDT), aarklon@gmail.com wrote in
comp.lang.c:

> Hi all,
>
> see:- http://mathforum.org/library/drmath/view/54456.html

Even better:

double pi = acos(-1);

Of course, if you want it outside of a function, you can't initialize
it with a function, so instead:

double pi;

int main(void)
{
pi = acos(-1);
/* stuff */
return 0;
}

Don't forget to include <math.h>, and you might have to do some extra
work in linking if you work on an antique system.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html

 0
Reply jackklein (3932) 5/25/2008 3:31:55 AM

On Sat, 24 May 2008 22:31:55 -0500, Jack Klein wrote:

> On Fri, 23 May 2008 20:53:16 -0700 (PDT), aarklon@gmail.com wrote in
> comp.lang.c:
>
>> Hi all,
>>
>> see:- http://mathforum.org/library/drmath/view/54456.html
>
> Even better:
>
>    double pi = acos(-1);
>
> Of course, if you want it outside of a function, you can't initialize it
> with a function, so instead:
>
> double pi;
>
> int main(void)
> {
>    pi = acos(-1);
>    /* stuff */
>    return 0;
> }

Or take it a step further and copy and paste the output of the following
program into a suitable header file.

/* pi.c */
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("#define PI %.32f\n", acos(-1.0));
return 0;
}

Output:

#define PI 3.14159265358979311599796346854419

> Don't forget to include <math.h>, and you might have to do some extra
> work in linking if you work on an antique system.

s/antique/linux

jaysome@ubuntu:/tmp$gcc -o pi pi.c /tmp/ccIx5hjS.o: In function main': pi.c:(.text+0x1c): undefined reference to acos' collect2: ld returned 1 exit status Of course the way to fix this is explained in the C FAQ: jaysome@ubuntu:/tmp$ gcc -o pi pi.c -lm

Regards
--
jay


 0
Reply andyg447 (4) 5/25/2008 7:05:01 AM

Andy G. wrote:
> On Sat, 24 May 2008 22:31:55 -0500, Jack Klein wrote:
>
>> On Fri, 23 May 2008 20:53:16 -0700 (PDT), aarklon@gmail.com wrote in
>> comp.lang.c:
>>
>>> Hi all,
>>>
>>> see:- http://mathforum.org/library/drmath/view/54456.html
>> Even better:
>>
>>    double pi = acos(-1);
>>
>> Of course, if you want it outside of a function, you can't initialize it
>> with a function, so instead:
>>
>> double pi;
>>
>> int main(void)
>> {
>>    pi = acos(-1);
>>    /* stuff */
>>    return 0;
>> }
>
> Or take it a step further and copy and paste the output of the following
> program into a suitable header file.
>
> /* pi.c */
> #include <math.h>
> #include <stdio.h>
> int main(void)
> {
>   printf("#define PI %.32f\n", acos(-1.0));
>   return 0;
> }
>
> Output:
>
> #define PI 3.14159265358979311599796346854419

That's wrong.
Pi is 3.14159265358979323846264338327950

> s/antique/linux
>
> jaysome@ubuntu:/tmp$gcc -o pi pi.c > /tmp/ccIx5hjS.o: In function main': > pi.c:(.text+0x1c): undefined reference to acos' > collect2: ld returned 1 exit status > > Of course the way to fix this is explained in the C FAQ: > > jaysome@ubuntu:/tmp$ gcc -o pi pi.c -lm
>
> Regards

--
pete

 0
Reply pfiland (6614) 5/25/2008 7:14:17 AM

"Andy G." <andyg447@spamcop.net> writes:
[...]
> Or take it a step further and copy and paste the output of the following
> program into a suitable header file.
>
> /* pi.c */
> #include <math.h>
> #include <stdio.h>
> int main(void)
> {
>   printf("#define PI %.32f\n", acos(-1.0));
>   return 0;
> }
>
> Output:
>
> #define PI 3.14159265358979311599796346854419

#include <float.h>
#define PI 3.141592653589792328462643383279502884197169399375105820974944592
#if LDBL_DIG > 64
#error "Need more digits for PI"
#endif

Or you can write code to compute it for you if you're concerned that
the value might change.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 5/25/2008 8:01:11 AM

Keith Thompson said:

> "Andy G." <andyg447@spamcop.net> writes:

<snip>

>>   printf("#define PI %.32f\n", acos(-1.0));
>>   return 0;
>> }
>>
>> Output:
>>
>> #define PI 3.14159265358979311599796346854419

His program's first error is in the 17th digit (the 16th decimal place).

> #include <float.h>
> #define PI
> #3.141592653589792328462643383279502884197169399375105820974944592

Your first error, however, is in the 16th digit (the 15th decimal place).
:-p

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/25/2008 8:10:54 AM

Richard Heathfield <rjh@see.sig.invalid> writes:
> Keith Thompson said:
>
>> "Andy G." <andyg447@spamcop.net> writes:
>
> <snip>
>
>>>   printf("#define PI %.32f\n", acos(-1.0));
>>>   return 0;
>>> }
>>>
>>> Output:
>>>
>>> #define PI 3.14159265358979311599796346854419
>
> His program's first error is in the 17th digit (the 16th decimal place).
>
>> #include <float.h>
>> #define PI
>> #3.141592653589792328462643383279502884197169399375105820974944592
>
> Your first error, however, is in the 16th digit (the 15th decimal place).
> :-p

Whoops.  s/232/323/

(His error was due to rounding; mine was a typo.)

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 5/25/2008 8:15:08 AM

On May 25, 11:15 am, Keith Thompson <ks...@mib.org> wrote:
> Richard Heathfield <r...@see.sig.invalid> writes:
> > Keith Thompson said:
>
> >> "Andy G." <andyg...@spamcop.net> writes:
>
> > <snip>
>
> >>>   printf("#define PI %.32f\n", acos(-1.0));
> >>>   return 0;
> >>> }
>
> >>> Output:
>
> >>> #define PI 3.14159265358979311599796346854419
>
> > His program's first error is in the 17th digit (the 16th decimal place).
>
> >> #include <float.h>
> >> #define PI
> >> #3.141592653589792328462643383279502884197169399375105820974944592
>
> > Your first error, however, is in the 16th digit (the 15th decimal place).
> > :-p
>
> Whoops.  s/232/323/
>
> (His error was due to rounding; mine was a typo.)
.... typo? You don't remember PI up to all these decimal places, do you?

 0
Reply vippstar (1211) 5/25/2008 2:31:47 PM

vippstar@gmail.com wrote:
> Keith Thompson <ks...@mib.org> wrote:
>> Richard Heathfield <r...@see.sig.invalid> writes:
>>> Keith Thompson said:
>>>> "Andy G." <andyg...@spamcop.net> writes:
>>
.... snip ...
>>
>>>>> #define PI 3.14159265358979311599796346854419
>>
>>> His program's first error is in the 17th digit (the 16th
>>> decimal place).
>>
>>>> #include <float.h>
>>>> #define PI
>>>> #3.141592653589792328462643383279502884197169399375105820974944592
>>
>>> Your first error, however, is in the 16th digit (the 15th
>>> decimal place).  :-p
>>
>> Whoops.  s/232/323/
>>
>> (His error was due to rounding; mine was a typo.)
>
> ... typo? You don't remember PI up to all these decimal places,
> do you?

Of course he does.  These are c.l.c regulars you are speaking to.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>

** Posted from http://www.teranews.com **

 0
Reply cbfalconer (19194) 5/25/2008 3:32:21 PM

vippstar@gmail.com writes:
> On May 25, 11:15 am, Keith Thompson <ks...@mib.org> wrote:
>> Richard Heathfield <r...@see.sig.invalid> writes:
>> > Keith Thompson said:
>>
>> >> "Andy G." <andyg...@spamcop.net> writes:
>>
>> > <snip>
>>
>> >>>   printf("#define PI %.32f\n", acos(-1.0));
>> >>>   return 0;
>> >>> }
>>
>> >>> Output:
>>
>> >>> #define PI 3.14159265358979311599796346854419
>>
>> > His program's first error is in the 17th digit (the 16th decimal place).
>>
>> >> #include <float.h>
>> >> #define PI
>> >> #3.141592653589792328462643383279502884197169399375105820974944592
>>
>> > Your first error, however, is in the 16th digit (the 15th decimal place).
>> > :-p
>>
>> Whoops.  s/232/323/
>>
>> (His error was due to rounding; mine was a typo.)
> ... typo? You don't remember PI up to all these decimal places, do you?

Yes.  From memory:

3.1415926535897932384626433832795028841971693993751058209749445923078164

I used fewer digits above to avoid making the line too long.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 5/25/2008 6:09:22 PM

On May 24, 5:41=A0pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> spinoza1111 said:
> > On May 24, 2:44 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> >> Presumably you want Pi? Easy. It's about 3.

I'm disappointed no one in the thread mentioned the
almost unbelievable expression due to Ramanujan:
\frac{1}{\pi} =3D \frac{2\sqrt{2}}{9801}
\sum^\infty_{k=3D0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}

Admittedly, this formula may have little interest for those

> No (but somehow I get the feeling that either I'm misinterpreting your
> question, or you're going to misinterpret my answer, or perhaps both).

Or perhaps even all three.

James Dow Allen

 0
Reply jdallen2000 (495) 5/26/2008 7:25:13 AM

James Dow Allen said:

> On May 24, 5:41 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> spinoza1111 said:
>> > On May 24, 2:44 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> >> Presumably you want Pi? Easy. It's about 3.
>
> I'm disappointed no one in the thread mentioned the
> almost unbelievable expression due to Ramanujan:
> \frac{1}{\pi} = \frac{2\sqrt{2}}{9801}
>      \sum^\infty_{k=0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}}

But someone did mention it. In case you missed the article, the message ID
check it out!

> Admittedly, this formula may have little interest for those

<grin> Well, "about 3" *is* an adequate approximation - on occasion. That
doesn't mean it's adequate for *all* uses.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/26/2008 8:38:19 AM

On May 26, 4:38=A0am, Richard Heathfield <r...@see.sig.invalid> wrote:
> James Dow Allen said:
>
> > On May 24, 5:41 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> >> spinoza1111 said:
> >> > On May 24, 2:44 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> >> >> Presumably you want Pi? Easy. It's about 3.
>
> > I'm disappointed no one in the thread mentioned the
> > almost unbelievable expression due to Ramanujan:
> > \frac{1}{\pi} =3D \frac{2\sqrt{2}}{9801}
> > =A0 =A0 =A0\sum^\infty_{k=3D0} \frac{(4k)!(1103+26390k)}{(k!)^4 396^{4k}=
}
>
> But someone did mention it. In case you missed the article, the message ID=

> check it out!
>
> > Admittedly, this formula may have little interest for those
>
> <grin> Well, "about 3" *is* an adequate approximation - on occasion. That
> doesn't mean it's adequate for *all* uses.
>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> "Usenet is a strange place" - dmr 29 July 1999

Well I also learned a sentence for PI to 20 something digits, but I
forgot it. It may be wandering somewhere online...

 0
Reply noagbodjivictor (58) 5/26/2008 1:39:29 PM

noagbodjivictor@gmail.com said:

> On May 26, 4:38 am, Richard Heathfield <r...@see.sig.invalid> wrote:

<snip>

>> <grin> Well, "about 3" *is* an adequate approximation - on occasion.
>> That doesn't mean it's adequate for *all* uses.
>
> Well I also learned a sentence for PI to 20 something digits, but I
> forgot it. It may be wandering somewhere online...

Sir, I bear a rhyme excelling
In mystic force and magic spelling;
Celestial sprites elucidate
All my own striving can't relate.

From memory - except for one word which I wasn't sure that I'd remembered
properly, so I just whizzed through the first twenty places of pi in my
head to check that, even if my choice ("striving") was wrong, at least it
had the right number of letters. That's the trouble with mnemonics -
they're so hard to remember.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/26/2008 3:10:26 PM

In article <fe42ee41-d734-441b-b626-8bd05bee0a98@8g2000hse.googlegroups.com>,
noagbodjivictor@gmail.com <noagbodjivictor@gmail.com> wrote:

>Well I also learned a sentence for PI to 20 something digits, but I
>forgot it. It may be wandering somewhere online...

Now I, even I, would celebrate in rhymes unapt
The great immortal Syracusan rivaled[*] nevermore
Who in his wondrous lore passed on before
Gave men his guidance how to circles mensurate.

[*] Must be American

-- Richard
--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)

 0
Reply richard91 (3692) 5/26/2008 3:12:15 PM

Richard Heathfield wrote:
> noagbodjivictor@gmail.com said:
>
>> On May 26, 4:38 am, Richard Heathfield <r...@see.sig.invalid> wrote:
>
> <snip>
>
>>> <grin> Well, "about 3" *is* an adequate approximation - on occasion.
>>> That doesn't mean it's adequate for *all* uses.
>>
>> Well I also learned a sentence for PI to 20 something digits, but I
>> forgot it. It may be wandering somewhere online...
>
> Sir, I bear a rhyme excelling
> In mystic force and magic spelling;
> Celestial sprites elucidate
> All my own striving can't relate.
Or locate they who can cogitate
And so finally terminate. Finis.

Extends Pi to 31 digits...

Bye, Jojo


 0
Reply nospam.jojo (1344) 5/26/2008 3:15:12 PM

"Richard Heathfield" <rjh@see.sig.invalid> wrote in message
news:DZidnd9nY--PT6fVnZ2dnUVZ8vCdnZ2d@bt.com...
> noagbodjivictor@gmail.com said:
>
>> On May 26, 4:38 am, Richard Heathfield <r...@see.sig.invalid> wrote:
>
> <snip>
>
>>> <grin> Well, "about 3" *is* an adequate approximation - on occasion.
>>> That doesn't mean it's adequate for *all* uses.
>>
>> Well I also learned a sentence for PI to 20 something digits, but I
>> forgot it. It may be wandering somewhere online...
>
> Sir, I bear a rhyme excelling
> In mystic force and magic spelling;
> Celestial sprites elucidate
> All my own striving can't relate.
>
> From memory - except for one word which I wasn't sure that I'd remembered
> properly, so I just whizzed through the first twenty places of pi in my
> head to check that, even if my choice ("striving") was wrong, at least it
> had the right number of letters. That's the trouble with mnemonics -
> they're so hard to remember.

Good thing there wasn't a '0' in the first 20 places.

--
bartc


 0
Reply bc (2337) 5/26/2008 4:17:19 PM

Bartc said:
> "Richard Heathfield" <rjh@see.sig.invalid> wrote in message
> news:DZidnd9nY--PT6fVnZ2dnUVZ8vCdnZ2d@bt.com...
<snip>
>>
>> Sir, I bear a rhyme excelling
>> In mystic force and magic spelling;
>> Celestial sprites elucidate
>> All my own striving can't relate.
>>
>> From memory - except for one word which I wasn't sure that I'd
>> remembered properly, so I just whizzed through the first twenty places
>> of pi in my head to check [...]. That's the trouble
>> with mnemonics - they're so hard to remember.
>
> Good thing there wasn't a '0' in the first 20 places.

I am given to understand that the canonical technique for '0' is to use a
ten-letter word (e.g. "understand").

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 5/26/2008 4:53:54 PM

"pete" <pfiland@mindspring.com> wrote in message
> aarklon@gmail.com wrote:
>> Hi all,
>>
>> see:- http://mathforum.org/library/drmath/view/54456.html
>
> This works for me:
>
> #include <float.h>
> /*
> ** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
> */
> static double fs_pi(void);
>
> static double fs_pi(void)
> {
>     unsigned n;
>     double a, b;
>     static double p;
>     static int initialized;
>
>     if (!initialized) {
>         initialized = 1;
>         n = 1;
>         a = 3;
>         do {
>             a /= 9;
>             b  = a / n;
>             n += 2;
>             a /= 9;
>             b -= a / n;
>             n += 2;
>             p += b;
>         } while (b > DBL_EPSILON / 4);
>         n = 1;
>         a = 2;
>         do {
>             a /= 4;
>             b  = a / n;
>             n += 2;
>             a /= 4;
>             b -= a / n;
>             n += 2;
>             p += b;
>         } while (b > DBL_EPSILON / 2);
>         p *= 4;
>     }
>     return p;
> }

It's not really any better, but p can do double duty:

#include <float.h>
/*
** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
*/
static double   fs_pi(void);

static double   fs_pi(void)
{
unsigned        n;
double          a,
b;
static double   p = 0;

if (!p) {
n = 1;
a = 3;
do {
a /= 9;
b = a / n;
n += 2;
a /= 9;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 4);
n = 1;
a = 2;
do {
a /= 4;
b = a / n;
n += 2;
a /= 4;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 2);
p *= 4;
}
return p;
}

#ifdef UNIT_TEST
#include <stdio.h>
#include <math.h>
int             main(void)
{
const double    d = fs_pi();
printf("Pi approximation = %30.20g\n", d);
printf("Error is approximately %30.20g\n",
fabs(d - 3.1415926535897932384626433832795028841971693993751));
return 0;
}
#endif

** Posted from http://www.teranews.com **

 0
Reply dcorbit (2698) 5/28/2008 5:17:56 AM

On May 26, 8:10 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> noagbodjivic...@gmail.com said:
>
> > On May 26, 4:38 am, Richard Heathfield <r...@see.sig.invalid> wrote:
>
> <snip>
>
> >> <grin> Well, "about 3" *is* an adequate approximation - on occasion.
> >> That doesn't mean it's adequate for *all* uses.
>
> > Well I also learned a sentence for PI to 20 something digits, but I
> > forgot it. It may be wandering somewhere online...
>
> Sir, I bear a rhyme excelling
> In mystic force and magic spelling;
> Celestial sprites elucidate
> All my own striving can't relate.
>
> From memory - except for one word which I wasn't sure that I'd remembered
> properly, so I just whizzed through the first twenty places of pi in my
> head to check that, even if my choice ("striving") was wrong, at least it
> had the right number of letters. That's the trouble with mnemonics -
> they're so hard to remember.

see:- http://en.wikiquote.org/wiki/English_mathematics_mnemonics#Pi

 0
Reply aarklon (253) 6/1/2008 7:44:42 AM

On May 26, 3:38=A0pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> James Dow Allen said:
> > I'm disappointed no one in the thread mentioned the
> > almost unbelievable expression due to Ramanujan:
>
> But someone did mention it. In case you missed the article,
> the message ID
> is <4afeda9c-ee40-43de-a0ac-
> check it out!

Color me gullible, but I did search for this message,

But I agree: Great article!
>
> - on occasion. That
> doesn't mean it's adequate for *all* uses.

I wanted to post a rejoinder based on the famous
Tennessee legislation, but I discover that's an
urban legend.  Indiana did, once, *almost* legislate
a rational value for pi, as shown in an
article by Mark Brader, of rec.puzzles fame:
http://www-personal.umich.edu/~jlawler/aux/pi.html

While Googling for pi =3D 3, I also found that
this approximation is dictated by the Bible
in Chronicles II: 4:2-5.

Anyway, AFAIK, bank software doesn't use trig.
How *did* you divert all those half-farthings to

James

 0
Reply jdallen2000 (495) 6/2/2008 8:51:23 AM

James Dow Allen said:

> On May 26, 3:38 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> James Dow Allen said:
>> > I'm disappointed no one in the thread mentioned the
>> > almost unbelievable expression due to Ramanujan:
>>
>> But someone did mention it. In case you missed the article,
>> the message ID
>> is <4afeda9c-ee40-43de-a0ac-
>> check it out!
>
> Color me gullible,

No such word.

> I wanted to post a rejoinder based on the famous
> Tennessee legislation, but I discover that's an
> urban legend.  Indiana did, once, *almost* legislate
> a rational value for pi,

Oddly, a rational value of pi is irrational, whereas an irrational value is
rational.

> as shown in an
> article by Mark Brader, of rec.puzzles fame:

and indeed comp.lang.c fame (erstwhilely).

> While Googling for pi = 3, I also found that
> this approximation is dictated by the Bible
> in Chronicles II: 4:2-5.

Hardly a diktat - merely a reasonable estimate, and not at all bad for 2500
years ago. Even Archimedes (250 or so years later) could only manage to
establish that the true value was somewhere between 223/71 and 7/2.

> Anyway, AFAIK, bank software doesn't use trig.
> How *did* you divert all those half-farthings to

I could tell you, but then I'd have to bankrupt you.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

 0
Reply rjh (10790) 6/2/2008 11:34:54 AM

On May 28, 8:17 am, "Dann Corbit" <dcor...@connx.com> wrote:
> "pete" <pfil...@mindspring.com> wrote in message
>
>
>
>
> > aark...@gmail.com wrote:
> >> Hi all,
>
> >> see:-http://mathforum.org/library/drmath/view/54456.html
>
> > This works for me:
>
> > #include <float.h>
> > /*
> > ** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
> > */
Don't you mean pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4?

 0
Reply vippstar (1211) 6/2/2008 12:24:53 PM

vippstar@gmail.com writes:
> On May 28, 8:17 am, "Dann Corbit" <dcor...@connx.com> wrote:
>> "pete" <pfil...@mindspring.com> wrote in message
>>
>> > aark...@gmail.com wrote:
>> >> see:-http://mathforum.org/library/drmath/view/54456.html
>>
>> > This works for me:
>>
>> > #include <float.h>
>> > /*
>> > ** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
>> > */
> Don't you mean pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4?

Your "correction" was exactly the same as what pete wrote.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 6/2/2008 3:29:15 PM

On Jun 2, 1:51=A0am, James Dow Allen <jdallen2...@yahoo.com> wrote:
[snip]
> While Googling for pi =3D 3, I also found that
> this approximation is dictated by the Bible
> in Chronicles II: 4:2-5.
From:
http://mathworld.wolfram.com/Pi.html
"The Bible contains two references (I Kings 7:23 and Chronicles 4:2)
which give a value of 3 for pi (Wells 1986, p. 48). It should be
mentioned, however, that both instances refer to a value obtained from
physical measurements and, as such, are probably well within the
bounds of experimental uncertainty."
[snip]
This has been discussed a time or two both here and in
news:sci.math.num-analysis

 0
Reply dcorbit (2698) 6/2/2008 7:11:46 PM

In article <17b389c7-42ff-4745-8ff5-6b62afe3eb9c@e39g2000hsf.googlegroups.com>,
user923005  <dcorbit@connx.com> wrote:

>"The Bible contains two references (I Kings 7:23 and Chronicles 4:2)
>which give a value of 3 for pi (Wells 1986, p. 48). It should be
>mentioned, however, that both instances refer to a value obtained from
>physical measurements and, as such, are probably well within the
>bounds of experimental uncertainty."

The values given for circumference and diameter - 30 and 10 cubits -
are such that they could be correct to the nearest cubit.

-- Richard

--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)

 0
Reply richard91 (3692) 6/2/2008 7:59:29 PM

"Richard Tobin" <richard@cogsci.ed.ac.uk> wrote in message
news:g21jf1$i9c$1@pc-news.cogsci.ed.ac.uk...
> In article
> user923005  <dcorbit@connx.com> wrote:
>
>>"The Bible contains two references (I Kings 7:23 and Chronicles 4:2)
>>which give a value of 3 for pi (Wells 1986, p. 48). It should be
>>mentioned, however, that both instances refer to a value obtained from
>>physical measurements and, as such, are probably well within the
>>bounds of experimental uncertainty."
>
> The values given for circumference and diameter - 30 and 10 cubits -
> are such that they could be correct to the nearest cubit.

They didn't try very hard. A 10-cubit diameter circle is 15 feet across, and
a string (if they had strings?) around the circumference would be just over
47 feet, clearly about 3 1/7 times the diameter.

Even without using any units, just strings for diameter and circumference,
the short string would go into the long one 3 times, with a bit over roughly
equal to 1/7 of the short string.

--
Bartc


 0
Reply bc (2337) 6/2/2008 9:22:41 PM

"Bartc" <bc@freeuk.com> writes:
> "Richard Tobin" <richard@cogsci.ed.ac.uk> wrote in message
> news:g21jf1$i9c$1@pc-news.cogsci.ed.ac.uk...
>> In article
>> user923005  <dcorbit@connx.com> wrote:
>>
>>>"The Bible contains two references (I Kings 7:23 and Chronicles 4:2)
>>>which give a value of 3 for pi (Wells 1986, p. 48). It should be
>>>mentioned, however, that both instances refer to a value obtained from
>>>physical measurements and, as such, are probably well within the
>>>bounds of experimental uncertainty."
>>
>> The values given for circumference and diameter - 30 and 10 cubits -
>> are such that they could be correct to the nearest cubit.
>
> They didn't try very hard. A 10-cubit diameter circle is 15 feet across, and
> a string (if they had strings?) around the circumference would be just over
> 47 feet, clearly about 3 1/7 times the diameter.
>
> Even without using any units, just strings for diameter and circumference,
> the short string would go into the long one 3 times, with a bit over roughly
> equal to 1/7 of the short string.

I answered this last year.  See:

Message-ID <lnabu1basp.fsf@nuthaus.mib.org>

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 6/2/2008 10:08:23 PM

In article <BwZ0k.2255$E41.409@text.news.virginmedia.com>, Bartc <bc@freeuk.com> wrote: >> The values given for circumference and diameter - 30 and 10 cubits - >> are such that they could be correct to the nearest cubit. >They didn't try very hard. I think you're misunderstanding. It doesn't say "pi = 3" or anything like that. What it says is Also he made a molten sea of ten cubits from brim to brim, round in compass, and five cubits the height thereof; and a line of thirty cubits did compass it round about. This has often been humorously interpreted as the Bible saying "pi = 3", and has occasionally been seriously interpreted that way, though only by morons. It is quite possible to have a perfectly circular object whose diameter and circumference are, to the nearest cubit, 10 and 30 cubits respectively. For example, if the diameter were 9.6 cubits the circumference would be about 30.16. -- Richard -- In the selection of the two characters immediately succeeding the numeral 9, consideration shall be given to their replacement by the graphics 10 and 11 to facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)   0 Reply richard91 (3692) 6/2/2008 10:17:50 PM Keith Thompson said: > "Bartc" <bc@freeuk.com> writes: <snip> >> Even without using any units, just strings for diameter and >> circumference, the short string would go into the long one 3 times, with >> a bit over roughly equal to 1/7 of the short string. > > I answered this last year. See: > > Message-ID <lnabu1basp.fsf@nuthaus.mib.org> > http://groups.google.com/group/comp.lang.c/msg/bc377c76a108875f I'm impressed that your response to a discussion of the contents of one Bible managed to include references to two others. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ Google users: <http://www.cpax.org.uk/prg/writings/googly.php> "Usenet is a strange place" - dmr 29 July 1999   0 Reply rjh (10790) 6/2/2008 10:18:38 PM On Jun 2, 3:17=A0pm, rich...@cogsci.ed.ac.uk (Richard Tobin) wrote: > In article <BwZ0k.2255$E41....@text.news.virginmedia.com>,
>
> Bartc <b...@freeuk.com> wrote:
> >> The values given for circumference and diameter - 30 and 10 cubits -
> >> are such that they could be correct to the nearest cubit.
> >They didn't try very hard.
>
> I think you're misunderstanding.
>
> It doesn't say "pi =3D 3" or anything like that. =A0What it says is
>
> =A0 Also he made a molten sea of ten cubits from brim to brim, round in
> =A0 compass, and five cubits the height thereof; and a line of thirty
> =A0 cubits did compass it round about.
>
> This has often been humorously interpreted as the Bible saying
> "pi =3D 3", and has occasionally been seriously interpreted that way,
> though only by morons.
>
> It is quite possible to have a perfectly circular object whose
> diameter and circumference are, to the nearest cubit, 10 and 30 cubits
> respectively. =A0For example, if the diameter were 9.6 cubits the
> circumference would be about 30.16.

The measurement would probably have been made by men stretching rope,
with knots at cubit intervals around the rim.

In measuring the diameter, the rope would most certainly sag.

At any rate, if the Bible did contain the correct value of pi, it
would have been a good deal longer and a rather dull read.

IMO-YMMV.

 0
Reply dcorbit (2698) 6/2/2008 10:52:31 PM

Richard Heathfield <rjh@see.sig.invalid> writes:
> Keith Thompson said:
>> "Bartc" <bc@freeuk.com> writes:
> <snip>
>
>>> Even without using any units, just strings for diameter and
>>> circumference, the short string would go into the long one 3 times, with
>>> a bit over roughly equal to 1/7 of the short string.
>>
>> I answered this last year.  See:
>>
>> Message-ID <lnabu1basp.fsf@nuthaus.mib.org>
>
> I'm impressed that your response to a discussion of the contents of one
> Bible managed to include references to two others.

Sometimes the best response is multiple canon fire.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

 0
Reply kst-u (21963) 6/2/2008 11:00:54 PM

On Jun 2, 6:29 pm, Keith Thompson <ks...@mib.org> wrote:
> vipps...@gmail.com writes:
> > On May 28, 8:17 am, "Dann Corbit" <dcor...@connx.com> wrote:
> >> "pete" <pfil...@mindspring.com> wrote in message
>
> >> > aark...@gmail.com wrote:
> >> >> see:-http://mathforum.org/library/drmath/view/54456.html
>
> >> > This works for me:
>
> >> > #include <float.h>
> >> > /*
> >> > ** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4
> >> > */
> > Don't you mean pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4?
>
> Your "correction" was exactly the same as what pete wrote.
Indeed, I apologize. I was tired at the time.

 0
Reply vippstar (1211) 6/3/2008 5:09:42 AM

user923005 <dcorbit@connx.com> wrote:

> On Jun 2, 1:51=A0am, James Dow Allen <jdallen2...@yahoo.com> wrote:
> [snip]
> > While Googling for pi =3D 3, I also found that
> > this approximation is dictated by the Bible
> > in Chronicles II: 4:2-5.
> From:
> http://mathworld.wolfram.com/Pi.html
> "The Bible contains two references (I Kings 7:23 and Chronicles 4:2)
> which give a value of 3 for pi (Wells 1986, p. 48). It should be
> mentioned, however, that both instances refer to a value obtained from
> physical measurements and, as such, are probably well within the
> bounds of experimental uncertainty."
> [snip]

Oh, come on. It's much more cut and dried than that. In both cases, the
measurements are given with one single digit of precision. So all they
state is that, to within that single digit, pi is 3. Guess what? _To
within that one digit_, pi _is_ 3.

Richard

 0
Reply rlb (4118) 6/3/2008 6:04:29 AM

In article <4844deaa.410072525@news.xs4all.nl>,
Richard Bos <rlb@hoekstra-uitgeverij.nl> wrote:

>Oh, come on. It's much more cut and dried than that. In both cases, the
>measurements are given with one single digit of precision.

You can't the intended precision just by looking at the data.  10 and
30 cubits *might* be accurate to one significant figure.  More likely,
they're intended to be accurate to the nearest cubit.  The fact that
they are multiples of 10 may well have been a deliberate choice in the
actual size rather than indicating the precision of the reported
values.

-- Richard
--
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)

 0
Reply richard91 (3692) 6/3/2008 9:36:33 AM

42 Replies
45 Views

Similar Articles

12/12/2013 4:15:12 AM
[PageSpeed]

Similar Artilces:

Unification algorithm in C/C++
I am looking for an efficient implementation of Unification algorithm in C/C++ for my research. No functional languages please. I would appreciate any kind of help. Thanks in advance, Sunanda. I wrote a simple PROLOG interpreter many years ago (my first C++ program). It uses a very simple unification algorithm, but of course the real complexity stay in variables handling... If you need the full code, I can send it to you... The code I pasted here has lost any formatting, but sources are more readable... //----------------------------------------------------- // generate MGU of terms t1, t2...

Is there any place I can find some "small" projects (using c/c++/c#/java)?
Hi Guys, Is there any place I can find some "small" projects (using c/c++/c#/java) to earn some extra bucks? "ingres2008" <ingres2008@yahoo.com> wrote in message news:5c6f18d7.0310071817.7f3b495e@posting.google.com... > Hi Guys, Is there any place I can find some "small" projects (using > c/c++/c#/java) to earn some extra bucks? Try a help wanted group. We only discuss the C++ language here, this is not a job marketplace. -Mike ...

Algorithm to create a complete binary tree in C or C++!
does anybody have an algorithm to create a complete binary tree in C or C++ can't seem to find them anywhere. On Thu, 4 Mar 2004, CLEAVEAGE wrote: > > does anybody have an algorithm to create a complete binary tree in > C or C++ can't seem to find them anywhere. First of all, you don't write "algorithms" in C or C++; you write "programs" (or more granularly, "functions," or more abstractly, "packages" or "libraries"). Second of all, sure. struct Tree { void *Data; Tree *Left; Tree *Right; Tree(v...

Find a file with c++
Hello, I'm trying to make a c++ program that first looks for a specific file and then edits it. This file can be everywhere on the computer. Someone any idea how i can search the computer for a specific file in c++ ? Greetings, Ken Ken wrote: > Hello, > > I'm trying to make a c++ program that first looks for a specific file > and then edits it. This file can be everywhere on the computer. > Someone any idea how i can search the computer for a specific file in > c++ ? > > Greetings, > > Ken There are no facilities in C++ for searching for files. Y...

find in which triangle algorithm
Hello, I have a matrix of points, and a simple patch of triangles. I have the indices of those triangles and the coordenates of the vertices. I need to find in which of the triangle, is each point. p is the matrix with the points tri are the indices of the triangles in the form [12 13 14, 21 2 3, etc] face_triangulos are the coordinates of the points which formed the triangles I am assinging for each point the form [x y z T], where T is the triangle in which the point is contained. z is always zero .. p = [p, zeros(size(p,1),1)]; for I=1:size(tri,1) for J=1:size(p,1) ...

Apriori Algorithm in C
Hi, I need a simple implementation of the apriori algorithm in c.The ones available in the net are too complex.Thanks for any help. Eric On 22 Sep 2006 11:24:53 -0700, in comp.lang.c , dis_is_eagle@yahoo.com wrote: >Hi, > I need a simple implementation of the apriori algorithm in c.The >ones available in the net are too complex.Thanks for any help. Unfortunately the topic of comp.lang.c is the C language. A better place to ask for algos would be comp.programming. Be aware that if all the options in your websearch were too complex, including all the textbook and lesson ...

problem with C++ sort algorithm
Hello all, First i would like to thank the innumerable C++ faithfuls who slammed, castigated, berated and criticized me for trying to java-ize the STL list class :) Currently i have a vector<Obj*> of objects that i sort using sort( vector.begin(), vector.end(), myCompareMethod ) and i get a core dumped in myCompareMethod( obj* obj1, obj* obj2 ) because apparently obj2 is NULL. Now none of the objects in my vector are NULL, so i don't know how it could possibly get a NULL obj2 in the compare method? Any ideas? Thanks, Nilesh [ See http://www.gotw.ca/resources/clcm.htm for...

Combinations/permutations algorithm in C++
Hi, I want to write a function of four parameters. Each parameter can be of type long, double or string. For example: f(long, long, long, long); f(long, long, long, double); f(long, long, long, const string &); f(long, long, double, long); f(long, long, string, long); f(long, long, double, double); f(long, long, double, string); f(long, long, string, long); . . . I would like write this code automaticaly. I know the next_permutation STL algorithm, but I think that it is not useful in this case. Any idea ? Thanks, Jose Luis. On 13 Apr 2004 03:44:18 -0700, jose_luis_fdez_diaz_n...

Translating an embedded C algorithm
Hi, I am in the process of writing a book about real-time embedded development (hardware and software). In it there is a section on different programming languages that are available for embedded development. I'm using a small C function that does temperature measurement by linear interpolation of a lookup table as an example. I have C code to do this, and would like to have the same algorithm implemented in other languages. Unfortunately I'm really a C programmer, with very little experience of other languages, so I would like to ask if anyone on this newsgroup is interested in tran...

Need help in finding an efficient algorithm

tool to find .h dependencies in C++
Hi, I am working at a C++ project with many .h files. In the Makefile, for each .cc file I need to list the .h files on which the .cc file depends on so that it is recompiled whenever any of those changes. What tool would you recommended for finding .h dependencies for a given ..cc file? Thanks a lot, Ray Hi, Ray $(CPP)$(INC_DIR) -MM -MF "$(DEPDIR)/$*.dep" -c $< g++ -I./includes -I./headers -MM -MF myclass.dep -c myclass.cpp It's really easy to make target in Makefile to produce dependecies files for each *.cpp As example ..PHONY : dep DEPS=$(SRCS:.cpp=.dep) dep:...

Newbee help in finding C++ book
{ it is always a good idea to check newsgroup archives before posting see http://groups.google.com/group/comp.lang.c++.moderated . -mod } I have programmed for many years in C, and now need to learn C++. I have several books on the topic, but need a current one which references programs that will run under XP. All the ones I have either contain floppies or CD's which I cannot run, or reference web site which no longer exist. TIA [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] > I have program...

Trouble finding information in C++ standard
Can someone tell me where the standard says that this will be zero initialized: int i = int(); ....but this will not: int i; I can't seem to find it. Aaron -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] Aaron Graham wrote: > Can someone tell me where the standard says that this will be zero > initialized: > > int i = int(); > > ...but this will not: > > int i; > > I can't seem to find it. See 8.5 (all paragraphs before 8.5.1). V -- Please remove capital &...

Need C# Coding for MD5 Algorithm...
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks In Advance to all....................... With Regards, Sanjay.C > I need C# code for Implementing MD5 Algorithm. So ask in a C# group. Python's is here http://docs.python.org/lib/module-md5.html > please Send... ITs URgent http://www.catb.org/~esr/faqs/smart-questions.html#urgent On 28 May 2006 23:29:11 -0700, "Charleees" <vcharles2k@gmail.com> declaimed the following ...

Anyway to find the complexity of the ESPRIT Algorithm in Spectralanalysis ?
Hi , I was wondering if someone did this before and tried to measure the complexity of ESPRIT Algo for spectral estimation in relation to the parameters we need to know like ( m , number of samples and so on ) ... Thanks >Hi , >I was wondering if someone did this before and tried to measure the complexity of ESPRIT Algo for spectral estimation in relation to the parameters we need to know like ( m , number of samples and so on ) ... > >Thanks > > > Hi, Try to make a list with all the steps of the ESPRIT algorithm (including the computational complexity for...

Where can I find a good C editor (free)
Hello, I need a free C/C++ editor with syntax highlighting and a good interface to make utility. I appreciate your help on introducing me one. I am using ScrEdit now, but I think thee should be some more sophisticated one around. Best regards On Mon, 05 Jun 2006 14:41:21 GMT, ma wrote: > Hello, > > I need a free C/C++ editor with syntax highlighting and a good interface > to make utility. I appreciate your help on introducing me one. I am using > ScrEdit now, but I think thee should be some more sophisticated one around. > > > > Best regards ...

How to find out if a kernel module is loaded from C code?
Greetings, I'd like to determine if my driver has been loaded without actually loading it myself through an open() call. Is there a better way than popen("/usr/sbin/modinfo | grep mymodule","r")? Thanks, Marvin <mjust4@yahoo.com> wrote in message news:1128642364.388134.297010@g44g2000cwa.googlegroups.com... > Greetings, > > I'd like to determine if my driver has been loaded without actually > loading it myself through an open() call. Is there a better way than > popen("/usr/sbin/modinfo | grep mymodule","r")? > > ...

STL
Is there an STL algorithm that will return true if each element in coll1 is present in coll2 Dylan wrote: > Is there an STL algorithm that will return true if each element in > coll1 is present in coll2 I don't know of one specifically for this, but if this was the case, the result from set_difference would be empty (this requires both collections to be sorted). -- Later, Jerry. The universe is a figment of its own imagination. Dylan wrote: > Is there an STL algorithm that will return true if each element in > coll1 is present in coll2 If you want to check if ...

Finding a library decompress enhance deflate algorithm
Hello... i'm a freelance software developer... i'm trying to find an open-source, free or public domain library to decompress/read enhance deflate algorithm in c/c++... do anybody know where to get this? "mypapit" <papit01@lycos.com> wrote in message news:ac87adf8.0408251903.193f0423@posting.google.com... > Hello... i'm a freelance software developer... > > i'm trying to find an open-source, free or public domain library to > decompress/read enhance deflate algorithm in c/c++... > > do anybody know where to get this? http://www.gzip.org/zli...

Does C++ have a standard symbol representing the value Pi?
I can get the accurate value of Pi to an arbitrary precision, but it would be nice to have it directly and readily available as a standard feature of the language. Have I overlooked something, or is it not there? ISO/IEC14882:2003(E) offers me this: template<class T> complex<T> log(const complex<T>& x); "4 Notes: the branch cuts are along the negative real axis. 5 Returns: the complex natural (base e) logarithm of x, in the range of a strip mathematically unbounded along the real axis and in the interval [-i times pi, i times pi ] along the imaginary axis. When...