📄 math.java
字号:
/************************************************************************This file is part of java core libraries for the simpleRTJ virtual machine.This file is covered by the GNU GPL with the following exception: As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL RTJ COMPUTING BE LIABLE FOR ANY CLAIM, DAMAGESOR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.Created/modified by: RTJ Computing***********************************************************************/package java.lang;final public class Math{ final public static float E = (float)2.7182818284590452354; final public static float PI = (float)3.14159265358979323846;// public static Random randomGenerator = new Random();// native public static double IEEEremainder(double f1, double f2); public static float abs(float a) { if (a < 0.0f) { return -a; } return a; } public static int abs(int a) { if (a < 0) { return -a; } return a; } public static float max(float a, float b) { if (b > a) { return b; } return a; } public static int max(int a, int b) { if (b > a) { return b; } return (a); } public static float min(float a, float b) { if (a < b) { return a; } return b; } public static int min(int a, int b) { if (a < b) { return a; } return b; }/* To add support for the following native method add their definitions into ClassLinker.control file (located in lib\ClassLinker.jar) as weel as into j_lang.c. Make sure that the order of methods is the same is in ClassLinker.control. native public static float sin(float a); native public static float asin(float a); native public static float cos(float a); native public static float acos(float a); native public static float tan(float a); native public static float atan(float a); native public static float atan2(float a, float b); native public static float ceil(float a); native public static float sqrt(float a); native public static float exp(float a); native public static float floor(float a); native public static float log(float a); native public static float pow(float a, float b); native public static float rint(float a); public static int round(float a) { if ((a < (float)Integer.MIN_VALUE) || (a == Float.NEGATIVE_INFINITY)) { return Integer.MIN_VALUE; } else if ((a > (float)Integer.MAX_VALUE) || (a == Float.POSITIVE_INFINITY)) { return Integer.MAX_VALUE; } return (int)rint(a); }*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -