This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sqrt interpreter Q


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]