Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/aarch64/DoubleArithTests.java
32282 views
1
public class DoubleArithTests {
2
3
private static double test_neg(double a) {
4
return -a;
5
}
6
7
private static double test_add(double a, double b) {
8
return a + b;
9
}
10
11
private static double test_sub(double a, double b) {
12
return a - b;
13
}
14
15
private static double test_mul(double a, double b) {
16
return a * b;
17
}
18
19
private static double test_div(double a, double b) {
20
return a / b;
21
}
22
23
private static double test_rem(double a, double b) {
24
return a % b;
25
}
26
27
private static void assertThat(boolean assertion) {
28
if (! assertion) {
29
throw new AssertionError();
30
}
31
}
32
33
public static void main(String[] args) {
34
assertThat(test_neg(10.0) == -10.0);
35
assertThat(test_add(3.0, 2.0) == 5.0);
36
37
assertThat(test_sub(40.0, 13.0) == 27.0);
38
39
assertThat(test_mul(5.0, 200.0) == 1000.0);
40
41
assertThat(test_div(30.0, 3.0) == 10.0);
42
assertThat(test_div(30.0, 0.0) == Double.POSITIVE_INFINITY);
43
44
assertThat(test_rem(30.0, 3.0) == 0.0);
45
assertThat(test_rem(29.0, 3.0) == 2.0);
46
assertThat(Double.isNaN(test_rem(30.0, 0.0)));
47
48
}
49
}
50
51