blob: 62166383c326c9dfc933c3674d30b5e56c93fb9a [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/**
20 * Math routines similar to those found in {@link java.lang.Math}. Performs
21 * computations on {@code float} values directly without incurring the overhead
22 * of conversions to and from {@code double}.
23 *
24 * <p>On one platform, {@code FloatMath.sqrt(100)} executes in one third of the
25 * time required by {@code java.lang.Math.sqrt(100)}.</p>
26 */
27public class FloatMath {
28
29 /** Prevents instantiation. */
30 private FloatMath() {}
31
32 /**
33 * Returns the float conversion of the most positive (i.e. closest to
34 * positive infinity) integer value which is less than the argument.
35 *
36 * @param value to be converted
37 * @return the floor of value
38 */
39 public static native float floor(float value);
40
41 /**
42 * Returns the float conversion of the most negative (i.e. closest to
43 * negative infinity) integer value which is greater than the argument.
44 *
45 * @param value to be converted
46 * @return the ceiling of value
47 */
48 public static native float ceil(float value);
49
50 /**
51 * Returns the closest float approximation of the sine of the argument.
52 *
53 * @param angle to compute the cosine of, in radians
54 * @return the sine of angle
55 */
56 public static native float sin(float angle);
57
58 /**
59 * Returns the closest float approximation of the cosine of the argument.
60 *
61 * @param angle to compute the cosine of, in radians
62 * @return the cosine of angle
63 */
64 public static native float cos(float angle);
65
66 /**
67 * Returns the closest float approximation of the square root of the
68 * argument.
69 *
70 * @param value to compute sqrt of
71 * @return the square root of value
72 */
73 public static native float sqrt(float value);
74}