blob: bdcf5ca2bc9e046936122f0221e940fcef778078 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.util;
18
19/**
Elliott Hughesf732a2f2013-02-26 09:28:17 -080020 * 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 Fullerbbf88712014-10-23 11:57:06 +010024 *
25 * @deprecated Use {@link java.lang.Math} instead.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026 */
Neil Fullerbbf88712014-10-23 11:57:06 +010027@Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028public 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 Brown5d728bb2012-08-08 01:47:10 -070075
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 Brown270e3382012-08-16 01:30:22 -070084
85 /**
Jeff Browne2c279e2012-08-21 19:49:48 -070086 * 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 Brown270e3382012-08-16 01:30:22 -070096 * 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 Project9066cfe2009-03-03 19:31:44 -0800104}