This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: sqrt interpreter Q
- From: Andrew Haley <aph at cambridge dot redhat dot com>
- To: tromey at redhat dot com
- Cc: Andreas Tobler <toa at pop dot agri dot ch>, GCC-Java <java at gcc dot gnu dot org>
- Date: Fri, 8 Feb 2002 14:00:39 +0000 (GMT)
- Subject: Re: sqrt interpreter Q
- References: <3C62C85C.2665595A@pop.agri.ch><87adukr3hx.fsf@creche.redhat.com>
Tom Tromey writes:
> >>>>> "Andreas" == Andreas Tobler <toa@pop.agri.ch> writes:
>
> Andreas> Doing it with gij I get the following:
> Andreas> [titanium:~] andreast% gij my_sqrt
> Andreas> sqrt_int: -2147483648
> Andreas> sqrt_double: NaN
> Andreas> sqrt_long: -9223372034707292160
>
> I looked at this a bit.
> On x86 the appended program prints the `int' value.
> So I think the C++ compiler translates `(int) NaN' differently from
> the Java compiler.
Yeah, I wrote special code in the Java compiler to do the Right Thing.
It's:
/* Convert an IEEE real to an integer type. The result of such a
conversion when the source operand is a NaN isn't defined by
IEEE754, but by the Java language standard: it must be zero. Also,
overflows must be clipped to within range. This conversion
produces something like:
((expr >= (float)MAX_INT)
? MAX_INT
: ((expr <= (float)MIN_INT)
? MIN_INT
: ((expr != expr)
? 0
: (int)expr))) */
in java/typeck.c.
Andrew.