1 /* 2 * Copyright (C) 2007 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 package android.util; 18 19 /** 20 * Math routines similar to those found in {@link java.lang.Math}. On 21 * versions of Android with a JIT, these are significantly slower than 22 * the equivalent {@code Math} functions, which should be used in preference 23 * to these. 24 * 25 * @deprecated Use {@link java.lang.Math} instead. 26 */ 27 @Deprecated 28 public class FloatMath { 29 30 /** Prevents instantiation. */ FloatMath()31 private FloatMath() {} 32 33 /** 34 * Returns the float conversion of the most positive (i.e. closest to 35 * positive infinity) integer value which is less than the argument. 36 * 37 * @param value to be converted 38 * @return the floor of value 39 */ floor(float value)40 public static native float floor(float value); 41 42 /** 43 * Returns the float conversion of the most negative (i.e. closest to 44 * negative infinity) integer value which is greater than the argument. 45 * 46 * @param value to be converted 47 * @return the ceiling of value 48 */ ceil(float value)49 public static native float ceil(float value); 50 51 /** 52 * Returns the closest float approximation of the sine of the argument. 53 * 54 * @param angle to compute the cosine of, in radians 55 * @return the sine of angle 56 */ sin(float angle)57 public static native float sin(float angle); 58 59 /** 60 * Returns the closest float approximation of the cosine of the argument. 61 * 62 * @param angle to compute the cosine of, in radians 63 * @return the cosine of angle 64 */ cos(float angle)65 public static native float cos(float angle); 66 67 /** 68 * Returns the closest float approximation of the square root of the 69 * argument. 70 * 71 * @param value to compute sqrt of 72 * @return the square root of value 73 */ sqrt(float value)74 public static native float sqrt(float value); 75 76 /** 77 * Returns the closest float approximation of the raising "e" to the power 78 * of the argument. 79 * 80 * @param value to compute the exponential of 81 * @return the exponential of value 82 */ exp(float value)83 public static native float exp(float value); 84 85 /** 86 * Returns the closest float approximation of the result of raising {@code 87 * x} to the power of {@code y}. 88 * 89 * @param x the base of the operation. 90 * @param y the exponent of the operation. 91 * @return {@code x} to the power of {@code y}. 92 */ pow(float x, float y)93 public static native float pow(float x, float y); 94 95 /** 96 * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i> 97 * {@code y}</i><sup>{@code 2}</sup>{@code )}. 98 * 99 * @param x a float number 100 * @param y a float number 101 * @return the hypotenuse 102 */ hypot(float x, float y)103 public static native float hypot(float x, float y); 104 } 105