we're told to convert strings to double without using parse double or any math,int, or double function. I'm having a hard time converting the numbers using exponents.
public class Convert {
public static void main(String args[]) {
String num = "1223.230";
int d = 0, g = 0, c = 0, fnl = 0;
int exp = (num.indexOf(".") - 1);
while (num.charAt(d) != '.') {
g = num.charAt(d) - 48;
int k = 1;
for (int f = 0; f < exp; f++) {
k = (k * 10) * g;
}
fnl += k;
d++;
exp--;
System.out.println(fnl);
}
}
}
These codes only convert the int part of the given string and it prints the wrong answer.
parseDoubleand get an idea.1.23E-4).