我想知道字符串是否包含double var“nN”内的任何内容。
我试过
if(!line.matches(nN)) {
}
以下是我提问的更多代码
public double n;
private int x = 31; //maximun power for the int varible
private boolean number = false;
private double origanalN;
private double nN;
private double array[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
private int countNum[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
private int i = 0;
private String line = " ";
private double checkIf;
public void firstCalculation() {
origanalN = n;
while(x >= 0 || number == true) {
nN = Math.pow(2, x);
n = n - nN;
// System.out.println("\t\t\t " + n + " \t" + x);
if(n == 0) {
System.out.println(n + " equals 0 on the " + x + "th power");
System.exit(0);
}
if(n < 0) {
n = n + nN;
}
if(n != origanalN) {
if(!line.matches(nN)) {
}
line += nN + " ";
array[x] = n;
System.out.println("\t\t" + array[x] + " " + line);
}
// System.out.println(n + "\t\t");
x--;
}
}