Re:A list of practical projects that anyone can solve in any...
by dhartmei on Wednesday November 21, 2018 @04:00AM
(#18501193)
You don't need arbitrary precision, use a spigot https://en.wikipedia.org/wiki/Pi#Spigot_algorithms
[ Parent
| on HN ]
Re:A list of practical projects that anyone can solve in any...
by leni536 on Wednesday November 21, 2018 @05:15AM
(#18501489)
I took a look at a spigot algorithm[1]. I still think it needs arbitrary precision arithmetics but maybe I miss something obvious.
[1] https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%9...
Re:A list of practical projects that anyone can solve in any...
by dhartmei on Wednesday November 21, 2018 @05:21AM
(#18501508)
Here's an example if you want to try http://www.benzedrine.ch/pi-spigot.c
Re:A list of practical projects that anyone can solve in any...
by leni536 on Wednesday November 21, 2018 @05:33AM
(#18501565)
This doesn't look like a spigot algorithm. It has a link in the comments[1], it calculates the digits of PI from the beginning. The code you linked seems to implement the exact same algorithm.
I don't fully comprehend the code still, but the SCALE parameter suggest that it handles the elements of the array as a fixed point representation of real numbers. I wonder if it's correct for large number of digits.
Re:A list of practical projects that anyone can solve in any...
by ajuc on Wednesday November 21, 2018 @05:07AM
(#18501452)
Wow, this blew my mind. And it's so simple, too.
def nthHexDigitOfPI(n):
return 4/(8*n+1) - 2/(8*n+4) - 1/(8*n+5) - 1/(8*n+6)