📄 divtest.java
字号:
/* test that we don't get tripped up by x86 problem */public class divtest { public static int divfunc(int x, int y) { return x/y; } public static int modfunc(int x, int y) { return x%y; } public static void test(String s, int x, int y) { int r; try { r = divfunc(x, y); System.out.println (s + " / " + Integer.toHexString(r)); } catch (Throwable t) { System.out.println (s + " / " + t.toString()); } try { r = modfunc(x, y); System.out.println (s + " % " + Integer.toHexString(r)); } catch (Throwable t) { System.out.println (s + " % " + t.toString()); } } public static void main(String args[]) { test ("40000000 1", 0x40000000, 1); test ("80000000 1", 0x80000000, 1); test ("40000000 -1", 0x40000000, -1); test ("80000000 -1", 0x80000000, -1); // x86 causes trap for no good reason test ("40000000 2", 0x40000000, 2); test ("80000000 2", 0x80000000, 2); test ("40000000 -2", 0x40000000, -2); test ("80000000 -2", 0x80000000, -2); }}/* Expected Output:40000000 1 / 4000000040000000 1 % 080000000 1 / 8000000080000000 1 % 040000000 -1 / c000000040000000 -1 % 080000000 -1 / 8000000080000000 -1 % 040000000 2 / 2000000040000000 2 % 080000000 2 / c000000080000000 2 % 040000000 -2 / e000000040000000 -2 % 080000000 -2 / 4000000080000000 -2 % 0*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -