1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 import java.util.Locale;
18 
19 public class Main {
main(String args[])20   public static void main(String args[]) {
21     for (int i = 0; i <= 360; i += 45) {
22       double d = i * (Math.PI / 180.0);
23       System.out.println("Math.sin(" + d + ") = "
24           + String.format(Locale.US, "%.12f", Math.sin(d)));
25 
26       System.out.println("Math.sinh(" + d + ") = "
27           + String.format(Locale.US, "%.12f", Math.sinh(d)));
28       System.out.println("Math.asin(" + d + ") = "
29           + String.format(Locale.US, "%.12f", Math.asin(d)));
30       System.out.println("Math.cos(" + d + ") = "
31           + String.format(Locale.US, "%.12f", Math.cos(d)));
32       System.out.println("Math.cosh(" + d + ") = "
33           + String.format(Locale.US, "%.12f", Math.cosh(d)));
34       System.out.println("Math.acos(" + d + ") = "
35           + String.format(Locale.US, "%.12f", Math.acos(d)));
36       if ((i + 90) % 180 != 0) {
37         System.out.println("Math.tan(" + d + ") = "
38             + String.format(Locale.US, "%.12f", Math.tan(d)));
39       }
40       System.out.println("Math.tanh(" + d + ") = "
41           + String.format(Locale.US, "%.12f", Math.tanh(d)));
42       System.out.println("Math.atan(" + d + ") = "
43           + String.format(Locale.US, "%.12f", Math.atan(d)));
44       System.out.println("Math.atan2(" + d + ", " + (d + 1.0) + ") = "
45           + String.format(Locale.US, "%.12f", Math.atan2(d, d + 1.0)));
46     }
47 
48     for (int j = -3; j <= 3; j++) {
49       double e = (double) j;
50       System.out.println("Math.cbrt(" + e + ") = "
51           + String.format(Locale.US, "%.12f", Math.cbrt(e)));
52       System.out.println("Math.log(" + e + ") = "
53           + String.format(Locale.US, "%.12f", Math.log(e)));
54       System.out.println("Math.log10(" + e + ") = "
55           + String.format(Locale.US, "%.12f", Math.log10(e)));
56       System.out.println("Math.log1p(" + e + ") = "
57           + String.format(Locale.US, "%.12f", Math.log1p(e)));
58       System.out.println("Math.exp(" + e + ") = "
59           + String.format(Locale.US, "%.12f", Math.exp(e)));
60       System.out.println("Math.expm1(" + e + ") = "
61           + String.format(Locale.US, "%.12f", Math.expm1(e)));
62       System.out.println("Math.pow(" + e + ", " + (e + 1.0) + ") = "
63           + String.format(Locale.US, "%.12f", Math.pow(e, e + 1.0)));
64       System.out.println("Math.hypot(" + e + ", " + (e + 1.0) + ") = "
65           + String.format(Locale.US, "%.12f", Math.hypot(e, e + 1.0)));
66     }
67 
68     System.out.println("Math.ceil(0.0001) = "
69         + String.format(Locale.US, "%.12f", Math.ceil(0.0001)));
70     System.out.println("Math.floor(0.0001) = "
71         + String.format(Locale.US, "%.12f", Math.floor(0.0001)));
72     System.out.println("Math.nextAfter(1.0, 2.0) = "
73         + String.format(Locale.US, "%.12f", Math.nextAfter(1.0, 2.0)));
74     System.out.println("Math.nextAfter(2.0, 1.0) = "
75         + String.format(Locale.US, "%.12f", Math.nextAfter(2.0, 1.0)));
76     System.out.println("Math.rint(0.5000001) = "
77         + String.format(Locale.US, "%.12f", Math.rint(0.5000001)));
78 
79     for (int i = 0; i <= 360; i += 45) {
80       double d = i * (StrictMath.PI / 180.0);
81       System.out.println("StrictMath.sin(" + d + ") = " + StrictMath.sin(d));
82       System.out.println("StrictMath.sinh(" + d + ") = " + StrictMath.sinh(d));
83       System.out.println("StrictMath.asin(" + d + ") = " + StrictMath.asin(d));
84       System.out.println("StrictMath.cos(" + d + ") = " + StrictMath.cos(d));
85       System.out.println("StrictMath.cosh(" + d + ") = " + StrictMath.cosh(d));
86       System.out.println("StrictMath.acos(" + d + ") = " + StrictMath.acos(d));
87       System.out.println("StrictMath.tan(" + d + ") = " + StrictMath.tan(d));
88       System.out.println("StrictMath.tanh(" + d + ") = " + StrictMath.tanh(d));
89       System.out.println("StrictMath.atan(" + d + ") = " + StrictMath.atan(d));
90       System.out.println("StrictMath.atan2(" + d + ", " + (d + 1.0) + ") = "
91           + StrictMath.atan2(d, d + 1.0));
92     }
93 
94     for (int j = -3; j <= 3; j++) {
95       double e = (double) j;
96       System.out.println("StrictMath.cbrt(" + e + ") = " + StrictMath.cbrt(e));
97       System.out.println("StrictMath.log(" + e + ") = " + StrictMath.log(e));
98       System.out.println("StrictMath.log10(" + e + ") = " + StrictMath.log10(e));
99       System.out.println("StrictMath.log1p(" + e + ") = " + StrictMath.log1p(e));
100       System.out.println("StrictMath.exp(" + e + ") = " + StrictMath.exp(e));
101       System.out.println("StrictMath.expm1(" + e + ") = " + StrictMath.expm1(e));
102       System.out.println("StrictMath.pow(" + e + ", " + (e + 1.0) + ") = "
103           + StrictMath.pow(e, e + 1.0));
104       System.out.println("StrictMath.hypot(" + e + ", " + (e + 1.0) + ") = "
105           + StrictMath.hypot(e, e + 1.0));
106     }
107 
108     System.out.println("StrictMath.ceil(0.0001) = " + StrictMath.ceil(0.0001));
109     System.out.println("StrictMath.floor(0.0001) = " + StrictMath.floor(0.0001));
110     System.out.println("StrictMath.nextAfter(1.0, 2.0) = " + StrictMath.nextAfter(1.0, 2.0));
111     System.out.println("StrictMath.rint(0.5000001) = " + StrictMath.rint(0.5000001));
112   }
113 
114 }
115