1 Reply Latest reply: Mar 31, 2009 12:52 PM by 843810 RSS

    After casting double to float debugger shows wrong value

    843810
      Hi,
      My colleaque found an interesting behaviour with Java debugger. I have made some tests and here are the results:

      Test code:
      double dNum = 43.680659;
      float fNum = (float) dNum;
      
      System.out.println("double number = " + dNum);
      System.out.println("float number = " + fNum);
      This is tested in Eclipse IDE 3.4.2 with following Java JRE versions:
      - 1.4.2_19
      - 1.5.0_14
      - 1.6.0_10

      And following JDK:
      - jdk1.5.0_16

      Eclipse IDE will show following values for variables in all platforms:
      dNum = 43.680659
      fNum = 43.74316
      Console will print:
      double number = 43.680659
      float number = 43.68066
      Testing also with command line debugger jdb. Java JRE version:
      - 1.4.2_19

      And following JDK:
      - jdk1.5.0_16

      Results are the same as in Eclipse IDE. Is there a bug in debugger environment?