sqrt interpreter Q

Tom Tromey tromey@redhat.com
Thu Feb 7 20:33:00 GMT 2002


>>>>> "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.

I haven't looked into it more deeply than this.  It does suggest that
the f2* and d2* instructions in the interpreter might need to be
modified to handle the special cases.

Are you interested in researching this a bit more?

Tom


#include <stdio.h>
#include <math.h>

int main ()
{
  double d = -1;
  int l = (int) (sqrt (d));
  printf ("%d\n", l);
}



More information about the Java mailing list