Hello,

I'm trying to make a program that can calculate pi to several digits using the madhava sequence. The math part is irrelevant to my problem though. I want to calculate pi beyond 16 digits, which is the most precise form of numeric storage (in the variable type 'double'). So, I am going to save it as a string as it goes. For some reason though, I cannot convert the number into a string.

The idea is that it calculates a few digits, and then adds it to the string. When I sayCode:`//the whole class/program`

package pigenerator;

public class Main {

static String pistring = " ";

static double pinum = 0;

static int denominator = 1;

static int limit = 2000000000;

static boolean add = true;

static int digits = 0;

public void Main() {

}

public static void main(String[] args) {

findpi();

}

public static void findpi() {// based on madhava series

while (denominator < limit) {

boolean toggle = add;

if (add == true) {

pinum += 4 / denominator;

add = false;

}

if (toggle == false) {

pinum -= 4/ denominator;

add = true;

}

denominator += 2;

digits++;

if(digits>4)

{

pistring+=pinum.toString();// here occurs the error

digits=0;

}

System.out.println(pistring);

}

}

}

I get an error saying 'double cannot be dereferenced'. Any ideas about what might be causing this error are greatly appreciated. Also, don't worry about the math or anything other than the 'toString()' line. I know that the rest is all fine. Thank you so much.Code:`pistring+=pinum.toString();`