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]

Re: sqrt interpreter Q


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.


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