The interpreter of JDK 1.2.2 RC2 still has the bug
mentioned below.
Sun's JIT and TYA can handle the case correctly.


On Wed, 23 Jun 1999 20:35:35 -0700
[EMAIL PROTECTED](Matt Welsh)  said:

> The following program causes the Linux JDK 1.1.7v3 to crash with a
> SIGFPE. This is because the x86 causes an arithmetic exception when
> you divide 0x80000000 by -1; the JVM spec, however, says that the result
> of this should be 0x80000000 with NO exception thrown. (The fix is to catch 
> the SIGFPE and tweak the stack with the right value.)

> public class divtest {
>
>    public static int divfunc(int x, int y) {
>      return x/y;
>    }
>
>    public static void main(String args[]) {
>
>      int i = 0x80000000;
>      int j = -1;
>
>      int k = divfunc(i,j);
>      System.out.println("Result is "+Integer.toHexString(k));
>   }
>
> }


Kazuyuki SHUDO                          Happy Hacking!
  Muraoka Lab., Grad. School of Sci. & Eng., Waseda Univ.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to