gamberoillecito:
Hi everyone,
I'm trying to make a machine that calculates pi one digit at a time. I've already checked on the internet and I've found the bbp (Bailey-Borwein-Plouffe) formula which can do that but apparently only in hex and maybe binary.
I'm trying to figure out if there is a way to do the same thing using decimal numbers or either to convert the results of bbp algorithm in decimal i.e. converting hexadecimal pi to decimal pi.
The BBP algorithm is for calculation of "hex digits" of PI ONLY.
There is no possibility to calculate the Nth decimal place of PI in a similar way like it is with the Nth "hex digit".
There is a similar topic in this forum, started earlier this year in January, 2017:
https://forum.arduino.cc/index.php?topic=451743.0
In February I had put a lot of efforts in into programming some Arduino code for Bailey-Borwein-Plouffe algorithm running on Arduino UNO and posted the code in the other topic.
But it was a very frustrating experience: After posting the code for calculation of 4000 hex digits of PI, I got absolutely no comment or response from the starter of that thread.
But after I got no response from the starter of the topic for several weeks, I finally DELETED my code from the other topic, so it is GONE for now.
If you need decimal digits instead of hexdigits, it should be possible to create a decimal conversion algorithm.
BUT: You will first have to calculate a certain number of hex digits and store them intermediately, then have to convert them to decimal digits finally.
It should be doable for 1000 or 2000 decimal digits of PI on an UNO, I think (just a guess).
For number crunching of PI digits in decimal we need to have two things:
- calculation of hex digits
- expansion/conversion from hex digits to decimal digits
Are you ready?
As a first step I have some code for you, which can do none of the two steps:
The code just contains a pre-calculated list of some thousand hex digits of PI and displays the first 8366 of them on Serial.
In case anybody is interested in number crunching of PI digits with his Arduino, what would you like to
see next?
- code and example sketch for calculation of hex digits on an Arduino UNO?
- or my attempt to decode hex digits to their decimal representation?
If anybody would be interested, I'd put some more efforts into it and post some more PI related stuff and Arduino code.
But in case nobody wants to see more, I'll just keep my ideas and code for myself.
you decide: Either reply something like "show me more PI related code" when interested.
Or reply something like "keep the PI calculation for yourself" when not interested.
Or just don't reply at all, if you don't want to see PI number crunching code.
It's up to you, again.
In the file attachment you find some code for just displaying a list of hex digits of PI, which is pre-calculated and stored in PROGMEM. Nothing is calculated at runtime in that code.
sketch_may22a.ino (29.2 KB)