StrictMath.atan2 and StrictMath.pow methods returns incorrect values on AMD64 machine under Windows 2003.
To reproduce a failure please run the follwing test:
------------------test.java-------------------------
public class test {
public static void main(String[] argv) {
long atan_res = test_atan2(0xc008000000000000L, 0x7ff0000000000000L);
if( atan_res != 0x8000000000000000L) {
System.out.println("atan:" + Long.toHexString(atan_res));
}
long pow1_res = test_pow(0x8000000000000000L, 0x4008000000000000L);
if( pow1_res != 0x8000000000000000L) {
System.out.println("pow (1):" + Long.toHexString(pow1_res));
}
long pow2_res = test_pow(0xfff0000000000000L, 0xc008000000000000L);
if( pow2_res != 0x8000000000000000L) {
System.out.println("pow (2):" + Long.toHexString(pow2_res));
}
System.out.println("Finished!");
}
static long test_atan2(long arg1, long arg2) {
double darg1 = Double.longBitsToDouble(arg1);
double darg2 = Double.longBitsToDouble(arg2);
return Double.doubleToLongBits(StrictMath.atan2(darg1,darg2));
}
static long test_pow(long arg1, long arg2) {
double darg1 = Double.longBitsToDouble(arg1);
double darg2 = Double.longBitsToDouble(arg2);
return Double.doubleToLongBits(StrictMath.pow(darg1,darg2));
}
}
-----------------------------------------------
compile it:
$javac -d . test.java
and run:
$ N:\koori.sfbay\onestop\jdk\1.5.0\promoted\beta\b32c\binaries\windows-amd64\bin\java.exe -cp . test
atan:0
pow (1):0
pow (2):0
Finished!
Note that if you are running this test on 32-bit vm machine, the test is passed:
N:\koori.sfbay\onestop\jdk\1.5.0\promoted\beta\b32c\binaries\windows-i586\bin\java.exe -cp . test
Finished!
Also if you are running this test under linux-amd64 then the test is passed:
$ /net/koori.sfbay/onestop/jdk/1.5.0/promoted/beta/b32c/binaries/linux-amd64/bin/java -cp . test
Finished!
###@###.### 2004-01-30