FORTH for the SHARP PC-E500 (S)
|
06-21-2022, 02:16 AM
Post: #70
|
|||
|
|||
RE: FORTH for the SHARP PC-E500 (S)
Compute digits of pi.
The following Forth500 program is based on the C code to compute the digits of pi by Dik T. Winter, CWI Amsterdam. It computes up to 9864 digits of pi, but is memory-restricted to about 6000 digits max: Code: .( Loading BIG-PI...) A screenful with the first 152 digits of pi (this takes one minute to compute): Code: 152 big-pi A C program for the PC-G850(V)(S): Code: 1 unsigned long a=10000,d; The PC-G850VS calculates the first 152 digits of pi in 1 minute and 15 seconds. This slightly modified version in C with 64 bit integers correctly computes up to 54935 digits of pi: Code: uint64_t a=10000,b,c,d,e,*f,g; The 54936th digit is off by one, followed by 10000 instead of 0000: 362524395716152714669005814610000 ___________________________^x____ where a 7 should appear in place of the 6, falling the 1 to carry over to the 6. When pushing for 100000 digits this happens a few more times. I reckon the algorithm can be fixed to perform the carry. But this algorithm is quite slow for long digit sequences. There are also better algorithms, e.g. BBP, Chudnovsky. - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)