The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | /** |
Elliott Hughes | f732a2f | 2013-02-26 09:28:17 -0800 | [diff] [blame] | 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. |
Neil Fuller | bbf8871 | 2014-10-23 11:57:06 +0100 | [diff] [blame] | 24 | * |
| 25 | * @deprecated Use {@link java.lang.Math} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | */ |
Neil Fuller | bbf8871 | 2014-10-23 11:57:06 +0100 | [diff] [blame] | 27 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | public class FloatMath { |
| 29 | |
| 30 | /** Prevents instantiation. */ |
| 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 | */ |
| 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 | */ |
| 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 | */ |
| 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 | */ |
| 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 | */ |
| 74 | public static native float sqrt(float value); |
Jeff Brown | 5d728bb | 2012-08-08 01:47:10 -0700 | [diff] [blame] | 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 | */ |
| 83 | public static native float exp(float value); |
Jeff Brown | 270e338 | 2012-08-16 01:30:22 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
Jeff Brown | e2c279e | 2012-08-21 19:49:48 -0700 | [diff] [blame] | 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 | */ |
| 93 | public static native float pow(float x, float y); |
| 94 | |
| 95 | /** |
Jeff Brown | 270e338 | 2012-08-16 01:30:22 -0700 | [diff] [blame] | 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 | */ |
| 103 | public static native float hypot(float x, float y); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | } |