The idea of this method is to convert decimal numbers to fraction numbers. The only thing that's causing a problem is the line wert = wert * 10. When I run for example 7.52 in this method I get:
7.52
75.19999999999999
751.9999999999999
7519.999999999999
75199.9999999999
... and it goes on and on like this causing more problems. What am I missing? I want it to go like this 7.52 -> 75.2 -> 752.0.
public static Eintrag toBruchzahl(double wert) {
System.out.println(wert);
boolean isDone = false;
int k = 0;
while (!isDone) {
if (wert % 1 == 0) {
isDone = true;
Eintrag resultat = new Eintrag((int) wert, (int) Math.pow(10, k));
//resultat.normalisieren();
return resultat;
} else {
k++;
wert = wert * 10;
System.out.println(wert);
}
}
return null;
}