blob: bb7d15f1b40ee81d358dc69ac98c0b342624c41c [file] [log] [blame]
Rahul Ravikumar05336002019-10-14 15:04:32 -07001/*
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/**
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
33public class FloatMath {
34
35 /** Prevents instantiation. */
36 private FloatMath() {}
37
38 /**
39 * Returns the float conversion of the most positive (i.e. closest to
40 * positive infinity) integer value which is less than the argument.
41 *
42 * @param value to be converted
43 * @return the floor of value
44 * @removed
45 */
46 public static float floor(float value) {
47 return (float) Math.floor(value);
48 }
49
50 /**
51 * Returns the float conversion of the most negative (i.e. closest to
52 * negative infinity) integer value which is greater than the argument.
53 *
54 * @param value to be converted
55 * @return the ceiling of value
56 * @removed
57 */
58 public static float ceil(float value) {
59 return (float) Math.ceil(value);
60 }
61
62 /**
63 * Returns the closest float approximation of the sine of the argument.
64 *
65 * @param angle to compute the cosine of, in radians
66 * @return the sine of angle
67 * @removed
68 */
69 public static float sin(float angle) {
70 return (float) Math.sin(angle);
71 }
72
73 /**
74 * Returns the closest float approximation of the cosine of the argument.
75 *
76 * @param angle to compute the cosine of, in radians
77 * @return the cosine of angle
78 * @removed
79 */
80 public static float cos(float angle) {
81 return (float) Math.cos(angle);
82 }
83
84 /**
85 * Returns the closest float approximation of the square root of the
86 * argument.
87 *
88 * @param value to compute sqrt of
89 * @return the square root of value
90 * @removed
91 */
92 public static float sqrt(float value) {
93 return (float) Math.sqrt(value);
94 }
95
96 /**
97 * Returns the closest float approximation of the raising "e" to the power
98 * of the argument.
99 *
100 * @param value to compute the exponential of
101 * @return the exponential of value
102 * @removed
103 */
104 public static float exp(float value) {
105 return (float) Math.exp(value);
106 }
107
108 /**
109 * Returns the closest float approximation of the result of raising {@code
110 * x} to the power of {@code y}.
111 *
112 * @param x the base of the operation.
113 * @param y the exponent of the operation.
114 * @return {@code x} to the power of {@code y}.
115 * @removed
116 */
117 public static float pow(float x, float y) {
118 return (float) Math.pow(x, y);
119 }
120
121 /**
122 * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
123 * {@code y}</i><sup>{@code 2}</sup>{@code )}.
124 *
125 * @param x a float number
126 * @param y a float number
127 * @return the hypotenuse
128 * @removed
129 */
130 public static float hypot(float x, float y) {
131 return (float) Math.hypot(x, y);
132 }
133}