This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I get a different answer when using step into at the breakpoint than when running or debugging the following program using step over at the breakpoint. public static void main(String[] args){ //right angle triangle double a = Math.sqrt(2.0); double b = 1.0; double B = Math.PI/4; double expResult = Math.PI/2; Breakpoint--> double result = getAngle(a, b, B); System.out.println(result); } result is NaN when running or using step over at the above breakpoint, but is close (1.5707963118937354) to the correct value of PI/2 when using step into... public static double getAngle(double a, double b, double B){ double cosine=a*Math.cos(B); return Math.acos( Math.sqrt(cosine*cosine+(b-a)*(b+a))/b ); } I've tried using Sun JDK 1.5.0_09-b03 and Netbeans 5.5 (Build 200610171010) on Win 2K Pro and Win XP Pro and tried cleaning and rebuilding, and creating a new file in a new project with the same results.
I got always 1.5707963118937354 on Linux when running/debugging/stepping through the program on Linux. Needs to be explored on Windows... It's likely that the argument to Math.sqrt() gets negative.
A new day bring clarity... The following code shows that order of operator values can give different values on both my Win 2K Pro and Win XP Pro machines. The debugger must rearrange code with the assumption that a*b=b*a which doesn't seem to be true in this case? public static void main(String[] args){ double anglePair=0.7853981633974483; double multiple=1.414213562370951; double mathCos=Math.cos(anglePair); double mathCosMultiple=multiple*mathCos; double combinedFormula=multiple*Math.cos(anglePair); double mathCosMultiple2=mathCos*multiple; double combinedFormula2=Math.cos(anglePair)*multiple; System.out.println("anglePair="+anglePair); System.out.println("multiple="+multiple); System.out.println("mathCos="+mathCos); System.out.println("mathCosMultiple="+mathCosMultiple); System.out.println("combinedFormula="+combinedFormula); System.out.println("mathCosMultiple2="+mathCosMultiple2); System.out.println("combinedFormula2="+combinedFormula2); } gives me the output: anglePair=0.7853981633974483 multiple=1.414213562370951 mathCos=0.7071067811865476 mathCosMultiple=0.9999999999984841 combinedFormula=0.999999999998484 mathCosMultiple2=0.9999999999984841 combinedFormula2=0.9999999999984841
Can you please specify also the processor type, which you have? I've got consistent results on Intel(R) Pentium(R) M processor 2.00GHz with Linux: anglePair=0.7853981633974483 multiple=1.414213562370951 mathCos=0.7071067811865476 mathCosMultiple=0.9999999999984841 combinedFormula=0.9999999999984841 mathCosMultiple2=0.9999999999984841 combinedFormula2=0.9999999999984841 If debugger rearranges execution order, it's likely a bug in the JPDA debugger backend. I'll try that on Windows later on.
Ha, I've got it. It's a bug of JDK 1.5. When executed on JDK 1.6 it works fine. But JDK 1.5 produce the described faulty behavior. Since it's a JDK bug, we can not fix that in NetBeans. Use JDK 1.6 as a workaround.
Actually it seems to be a JRE bug, when compiled with JDK 1.5 and run with JRE 1.6 it works fine... Why is there an inconsistency in how step into and step over evaluation of code?