![]() |
Calculating Pi - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Calculating Pi (/thread-226166.html) |
Calculating Pi - Andrew Davie - 07-03-2012 I stumbled on a neat bit of C code when looking at the PB-2000C (a C-capable calculator, which is weird enough by itself). The code calculates Pi to any number of places. Here's it is...
long a=10000,b,c,d,e,*f,g; Compiled and ran it on my machine. I don't understand how it works, but it does. Could anyone with a bit of math skills please comment on what's actually happening here? It looks like magic to me.
Thanks Re: Calculating Pi - Egan Ford - 07-03-2012 Quote:Spigot (http://en.wikipedia.org/wiki/Spigot_algorithm). Read Pi Unleashed. Ch. 6 for a detailed explanation.
For Unbounded Spigot checkout:
A C version of the Unbounded Spigot: http://sense.net/~egan/hpgcc/#Unbounded%20Spigot%20Algorithm Edited: 3 July 2012, 11:30 a.m.
Re: Calculating Pi - Andrew Davie - 07-03-2012 .... wow. Edited: 3 July 2012, 4:55 p.m. after one or more responses were posted
Re: Calculating Pi [OT] - Tim Wessman - 07-03-2012 Side note - libtommath is in use in the 39gII. I've never found any good speed comparision between that and other (free/commercial) libraries. Anyone seen one before anywhere?
TW Edited: 3 July 2012, 3:24 p.m.
Re: Calculating Pi [OT] - Gjermund Skailand - 07-04-2012 I have a fairly comprehensive beta version of a longfloat library written in hpgcc3 for hp50g. Re: Calculating Pi [OT] - Egan Ford - 07-04-2012 Quote:Agreed for FP, but not for INT. libtommath is much faster for large integer math. At least based on the comparisons I did years ago. Re: Calculating Pi [OT] - Gjermund Skailand - 07-06-2012 Hi again, |