Calculating decimal digits of pi, using something similar to a Bailey–Borwein–Plouffe formula I have tried to Use the Bailey–Borwein–Plouffe formula to calculate pi to 3 digits as a test trial, and recieved the digit 4, which is technically correct, as 4 is the 3rd digit of pi in base 16. I would like to get the digit in decimal, as that is the current standard for numbering things in most places, as you don's see many things labelled D5 except in excel spreadsheets. Basically, I need to conduct a Bailey–Borwein–Plouffe formula from 0-6 (intead of 0 - infinity as i only need pi to 6 digits), but in decimal.

Here is what I had for the base 16 computation.

double pi2 = 0;
int n = 0;
while (n &lt; 3)
{
    double a = (1/(Math.pow(16, n)));
    double b = (4/((8*n) + 1));
    double c = (2/((8*n) + 4));
    double d = (1/((8*n) + 5));
    double e = (1/((8*n) + 6));
    pi2 += a*( b - c - d - e );
    n++;
}
The Bailey–Borwein–Plouffe formula only works in hexadecimal. There might be other formulas for other bases, but I'm not aware of a decimal-based formula. If you want to obtain the $N$th decimal digit, you have to compute enough hexadecimal digits, there are no shortcuts.