mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
9bb3d6b972
git-subtree-dir: sgx-jvm/avian git-subtree-mainline:f978eab8d1
git-subtree-split:09e4fe60d0
136 lines
2.5 KiB
Java
136 lines
2.5 KiB
Java
public class DivideByZero {
|
|
private static int divide(int n, int d) {
|
|
return n / d;
|
|
}
|
|
|
|
private static int modulo(int n, int d) {
|
|
return n % d;
|
|
}
|
|
|
|
private static long divide(long n, long d) {
|
|
return n / d;
|
|
}
|
|
|
|
private static long modulo(long n, long d) {
|
|
return n % d;
|
|
}
|
|
|
|
private static float divide(float n, float d) {
|
|
return n / d;
|
|
}
|
|
|
|
private static float modulo(float n, float d) {
|
|
return n % d;
|
|
}
|
|
|
|
private static double divide(double n, double d) {
|
|
return n / d;
|
|
}
|
|
|
|
private static double modulo(double n, double d) {
|
|
return n % d;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
try {
|
|
int x = 1 / 0;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
int x = 1 % 0;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
int y = 2;
|
|
int x = y / 0;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
int y = 2;
|
|
int x = y % 0;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
int z = 0;
|
|
int y = 2;
|
|
int x = y / z;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
int z = 0;
|
|
int y = 2;
|
|
int x = y % z;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
long z = 0;
|
|
long y = 2;
|
|
long x = y / z;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
long z = 0;
|
|
long y = 2;
|
|
long x = y % z;
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
divide(5, 0);
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
modulo(6, 0);
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
divide(5L, 0L);
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
modulo(6L, 0L);
|
|
throw new RuntimeException();
|
|
} catch (ArithmeticException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
divide(5F, 0F);
|
|
modulo(6F, 0F);
|
|
|
|
divide(5D, 0D);
|
|
modulo(6D, 0D);
|
|
}
|
|
}
|