4 static final double PI = 3.14159265358979323846;
6 // an alias for setPI()
7 public static double PI() {
8 double PI = 3.14159265358979323846;
12 public static int abs(int x) {
13 return (x < 0) ? -x : x;
16 public static long abs(long x) {
17 return (x < 0) ? -x : x;
20 public static double abs(double x) {
21 return (x < 0) ? -x : x;
24 public static float abs(float x) {
25 return (x < 0) ? -x : x;
28 public static double max(double a, double b) {
29 return (a > b) ? a : b;
32 public static float max(float a, float b) {
33 return (a > b) ? a : b;
36 public static int max(int a, int b) {
37 return (a > b) ? a : b;
40 public static long max(long a, long b) {
41 return (a > b) ? a : b;
44 public static double min(double a, double b) {
45 return (a < b) ? a : b;
48 public static float min(float a, float b) {
49 return (a < b) ? a : b;
52 public static int min(int a, int b) {
53 return (a < b) ? a : b;
56 public static long min(long a, long b) {
57 return (a < b) ? a : b;
60 /** sqrt(a^2 + b^2) without under/overflow. **/
61 public static double hypot(double a, double b) {
63 if (abs(a) > abs(b)) {
65 r = abs(a) * sqrt(1 + r * r);
68 r = abs(b) * sqrt(1 + r * r);
75 public static int round(float a) {
76 // this check for NaN, from JLS 15.21.1, saves a method call
77 return (int) floor(a + 0.5f);
80 public static double rint(double x) {
84 if (((int) y) % 2 == 0) {
95 public static native double sin(double a);
97 public static native double cos(double a);
99 public static native double asin(double a);
101 public static native double acos(double a);
103 public static native double tan(double a);
105 public static native double atan(double a);
107 public static native double atan2(double a, double b);
109 public static native double exp(double a);
111 public static native double sqrt(double a);
113 public static native double log(double a);
115 public static native double pow(double a, double b);
117 public static native double ceil(double a);
119 public static native double floor(double a);
121 public static native float sinf(float a);
123 public static native float cosf(float a);
125 public static native float expf(float a);
127 public static native float sqrtf(float a);
129 public static native float logf(float a);
131 public static native float powf(float a, float b);
133 public static native float ceilf(float a);
135 public static native float IEEEremainder(float f1, float f2);