This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
sqrt interpreter Q
- From: Andreas Tobler <toa at pop dot agri dot ch>
- To: GCC-Java <java at gcc dot gnu dot org>
- Date: Thu, 07 Feb 2002 19:32:59 +0100
- Subject: sqrt interpreter Q
- Organization: zero
Hi,
I see something strange here. (Actually testing my libffi port on darwin)
I compile the following snippet:
import java.math.*;
---
public class my_sqrt {
public static void main (String[] args) {
double my_double;
long my_long;
int my_int;
my_long = -1;
my_double = -1;
my_int = -1;
double d_last = (double)(Math.sqrt(my_double));
long l_last = (long)(Math.sqrt(my_long));
int l_int =(int)Math.sqrt(my_int);
System.out.println ("sqrt_int: "+l_int);
System.out.println ("sqrt_double: "+d_last);
System.out.println ("sqrt_long: "+l_last);
}
}
---
With a binary and with sun java I get this (as expected):
[titanium:~] andreast% ./my_sqrt
sqrt_int: 0
sqrt_double: NaN
sqrt_long: 0
Doing it with gij I get the following:
[titanium:~] andreast% gij my_sqrt
sqrt_int: -2147483648
sqrt_double: NaN
sqrt_long: -9223372034707292160
Is this obviously a problem in the libffi ? Or somewhere else?
One strange thing I see is, the integer is the biggest negativ one
defined. The long on the otherside is not the biggest negativ one. (-9223372036854775808)
Any lights?
Thanks,
Andreas