• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}.
21  *
22  * <p>Historically these methods were faster than the equivalent double-based
23  * {@link java.lang.Math} methods. On versions of Android with a JIT they
24  * became slower and have since been re-implemented to wrap calls to
25  * {@link java.lang.Math}. {@link java.lang.Math} should be used in
26  * preference.
27  *
28  * <p>All methods were removed from the public API in version 23.
29  *
30  * @deprecated Use {@link java.lang.Math} instead.
31  */
32 @Deprecated
33 @android.ravenwood.annotation.RavenwoodKeepWholeClass
34 public class FloatMath {
35 
36     /** Prevents instantiation. */
FloatMath()37     private FloatMath() {}
38 
39     /**
40      * Returns the float conversion of the most positive (i.e. closest to
41      * positive infinity) integer value which is less than the argument.
42      *
43      * @param value to be converted
44      * @return the floor of value
45      * @removed
46      */
floor(float value)47     public static float floor(float value) {
48         return (float) Math.floor(value);
49     }
50 
51     /**
52      * Returns the float conversion of the most negative (i.e. closest to
53      * negative infinity) integer value which is greater than the argument.
54      *
55      * @param value to be converted
56      * @return the ceiling of value
57      * @removed
58      */
ceil(float value)59     public static float ceil(float value) {
60         return (float) Math.ceil(value);
61     }
62 
63     /**
64      * Returns the closest float approximation of the sine of the argument.
65      *
66      * @param angle to compute the cosine of, in radians
67      * @return the sine of angle
68      * @removed
69      */
sin(float angle)70     public static float sin(float angle) {
71         return (float) Math.sin(angle);
72     }
73 
74     /**
75      * Returns the closest float approximation of the cosine of the argument.
76      *
77      * @param angle to compute the cosine of, in radians
78      * @return the cosine of angle
79      * @removed
80      */
cos(float angle)81     public static float cos(float angle) {
82         return (float) Math.cos(angle);
83     }
84 
85     /**
86      * Returns the closest float approximation of the square root of the
87      * argument.
88      *
89      * @param value to compute sqrt of
90      * @return the square root of value
91      * @removed
92      */
sqrt(float value)93     public static float sqrt(float value) {
94         return (float) Math.sqrt(value);
95     }
96 
97     /**
98      * Returns the closest float approximation of the raising "e" to the power
99      * of the argument.
100      *
101      * @param value to compute the exponential of
102      * @return the exponential of value
103      * @removed
104      */
exp(float value)105     public static float exp(float value) {
106         return (float) Math.exp(value);
107     }
108 
109     /**
110      * Returns the closest float approximation of the result of raising {@code
111      * x} to the power of {@code y}.
112      *
113      * @param x the base of the operation.
114      * @param y the exponent of the operation.
115      * @return {@code x} to the power of {@code y}.
116      * @removed
117      */
pow(float x, float y)118     public static float pow(float x, float y) {
119         return (float) Math.pow(x, y);
120     }
121 
122     /**
123      * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
124      * {@code y}</i><sup>{@code 2}</sup>{@code )}.
125      *
126      * @param x a float number
127      * @param y a float number
128      * @return the hypotenuse
129      * @removed
130      */
hypot(float x, float y)131     public static float hypot(float x, float y) {
132         return (float) Math.hypot(x, y);
133     }
134 }
135