| DoubleGenauigkeit.java |
1 /**
2 * 183.592 Programmierpraxis TU Wien WS2014/15 H.Moritsch
3 * Numerische Probleme mit double-Werten
4 */
5 public class DoubleGenauigkeit {
6 public static void main(String[] args) {
7
8 double x = 0.1; // 0.1 ist im Binärsystem nicht exakt darstellbar
9 double y = 1.0 + x - 1.0;
10
11 if ( x == y )
12 System.out.println("Werte gleich");
13 else
14 System.out.println("Unterschied beträgt " + (x - y));
15 }
16 }
17