📄 math.java
字号:
/* libaegisvm - The Aegis Virtual Machine for executing Java bytecode Copyright (C) 2001-2002 Philip W. L. Fong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/package java.lang;public final class Math { private static java.util.Random rg = null; private Math() { } public static final double E = Double.longBitsToDouble(0x4005bf0a8b145769L); public static final double PI = Double.longBitsToDouble(0x400921fb54442d18L); public static native double sin(double a); public static native double cos(double a); public static native double tan(double a); public static native double asin(double a); public static native double acos(double a); public static native double atan(double a); public static double toRadians(double angdeg) { return (angdeg / 180.0) * PI; } public static double toDegrees(double angrad) { return (angrad / PI) * 180.0; } public static native double exp(double a); public static native double log(double a); public static native double sqrt(double a); public static native double IEEEremainder(double f1, double f2); public static native double ceil(double a); public static native double floor(double a); public static native double rint(double a); public static native double atan2(double a, double b); public static native double pow(double a, double b); public static int round(float a) { if (a != a) return 0; else if (a <= (float) Integer.MIN_VALUE) return Integer.MIN_VALUE; else if (a >= (float) Integer.MAX_VALUE) return Integer.MAX_VALUE; else return (int) floor(a + 0.5f); } public static long round(double a) { if (a != a) return 0L; else if (a <= (double) Long.MIN_VALUE) return Long.MIN_VALUE; else if (a >= (double) Long.MAX_VALUE) return Long.MAX_VALUE; else return (long) floor(a + 0.5d); } public static synchronized double random() { if (rg == null) rg = new java.util.Random(); return rg.nextDouble(); } public static int abs(int a) { return (a < 0) ? -a : a; } public static long abs(long a) { return (a < 0) ? -a : a; } public static float abs(float a) { return Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a)); } public static double abs(double a) { return Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1); } public static int max(int a, int b) { return (a > b) ? a : b; } public static long max(long a, long b) { return (a > b) ? a : b; } public static float max(float a, float b) { if (a != a || b != b) return Float.NaN; else if (a == 0.0f && b == 0.0f) return (1.0f / a > 0.0f) ? a : b; else return (a > b) ? a : b; } public static double max(double a, double b) { if (a != a || b != b) return Double.NaN; else if (a == 0.0d && b == 0.0d) return (1.0d / a > 0.0d) ? a : b; else return (a > b) ? a : b; } public static int min(int a, int b) { return (a < b) ? a : b; } public static long min(long a, long b) { return (a < b) ? a : b; } public static float min(float a, float b) { if (a != 0 || b != b) return Float.NaN; else if (a == 0.0f && b == 0.0f) return (1.0f / a < 0.0f) ? a : b; else return (a < b) ? a : b; } public static double min(double a, double b) { if (a != 0 || b != b) return Double.NaN; else if (a == 0.0d && b == 0.0d) return (1.0d / a < 0.0d) ? a : b; else return (a < b) ? a : b; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -