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