public class Ma
extends java.lang.Object
An analog of standard java.lang.Math
class.
It contains all static methods and constants declared in
java.lang.Math
class and a convenient set of
the following additional methods:
iround(double)
minu(byte, byte)
maxu(byte, byte)
minu(short, short)
maxu(short, short)
minu(int, int)
maxu(int, int)
minu(long, long)
maxu(long, long)
min(byte, byte, byte)
max(byte, byte, byte)
median(byte, byte, byte)
min(short, short, short)
max(short, short, short)
median(short, short, short)
min(int, int, int)
max(int, int, int)
median(int, int, int)
min(long, long, long)
max(long, long, long)
median(long, long, long)
min(float, float, float)
max(float, float, float)
median(float, float, float)
min(double, double, double)
max(double, double, double)
median(double, double, double)
between(char, char, char)
between(byte, byte, byte)
between(short, short, short)
between(int, int, int)
between(long, long, long)
between(float, float, float)
between(float, float, float, float)
between(double, double, double)
between(double, double, double, double)
sqr(int)
}
sqr(long)
sqr(float)
sqr(double)
Be careful: min
and max
methods for float and
double values are not identical to the same methods from standard
java.lang.Math
class.
Modifier and Type | Field and Description |
---|---|
static double |
E
An equivalent of
java.lang.Math.E |
static double |
PI
An equivalent of
java.lang.Math.PI |
Modifier and Type | Method and Description |
---|---|
static double |
abs(double a)
An equivalent of
java.lang.Math.abs method. |
static float |
abs(float a)
An equivalent of
java.lang.Math.abs method. |
static int |
abs(int a)
An equivalent of
java.lang.Math.abs method. |
static long |
abs(long a)
An equivalent of
java.lang.Math.abs method. |
static double |
acos(double a)
An equivalent of
java.lang.Math.acos(a) |
static double |
asin(double a)
An equivalent of
java.lang.Math.asin(a) |
static double |
atan(double a)
An equivalent of
java.lang.Math.atan(a) |
static double |
atan2(double a,
double b)
An equivalent of
java.lang.Math.atan2(a,b) |
static boolean |
between(byte a,
byte b,
byte c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(char a,
char b,
char c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(double a,
double b,
double c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(double a,
double b,
double c,
double epsilon)
An equivalent of
a >= min(b, c) + epsilon && a <= max(b, c) - epsilon . |
static boolean |
between(float a,
float b,
float c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(float a,
float b,
float c,
float epsilon)
An equivalent of
a >= min(b, c) + epsilon && a <= max(b, c) - epsilon . |
static boolean |
between(int a,
int b,
int c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(long a,
long b,
long c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static boolean |
between(short a,
short b,
short c)
An equivalent of
a >= min(b, c) && a <= max(b, c) . |
static double |
ceil(double a)
An equivalent of
java.lang.Math.ceil(a) |
static double |
cos(double a)
An equivalent of
java.lang.Math.cos(a) |
static double |
exp(double a)
An equivalent of
java.lang.Math.exp(a) |
static double |
floor(double a)
An equivalent of
java.lang.Math.floor(a) |
static double |
IEEEremainder(double a,
double b)
An equivalent of
java.lang.Math.IEEEremainder(a,b) |
static int |
iround(double a)
An equivalent of
(int)java.lang.Math.round(a) call. |
static double |
log(double a)
An equivalent of
java.lang.Math.log(a) |
static byte |
max(byte a,
byte b)
An equivalent of
a >= b? a: b . |
static byte |
max(byte a,
byte b,
byte c)
Quicker equivalent of
max(a,max(b,c)) . |
static double |
max(double a,
double b)
An equivalent of
a >= b? a: b . |
static double |
max(double a,
double b,
double c)
Quicker equivalent of
max(a,max(b,c)) . |
static float |
max(float a,
float b)
An equivalent of
a >= b? a: b . |
static float |
max(float a,
float b,
float c)
Quicker equivalent of
max(a,max(b,c)) . |
static int |
max(int a,
int b)
An equivalent of
a >= b? a: b . |
static int |
max(int a,
int b,
int c)
Quicker equivalent of
max(a,max(b,c)) . |
static long |
max(long a,
long b)
An equivalent of
a >= b? a: b . |
static long |
max(long a,
long b,
long c)
Quicker equivalent of
max(a,max(b,c)) . |
static short |
max(short a,
short b)
An equivalent of
a >= b? a: b . |
static short |
max(short a,
short b,
short c)
Quicker equivalent of
max(a,max(b,c)) . |
static byte |
maxu(byte a,
byte b)
Returns maximum of two unsigned 8-bit integer values.
|
static int |
maxu(int a,
int b)
Returns maximum of two unsigned 32-bit integer values.
|
static long |
maxu(long a,
long b)
Returns maximum of two unsigned 64-bit integer values.
|
static short |
maxu(short a,
short b)
Returns maximum of two unsigned 16-bit integer values.
|
static byte |
median(byte a,
byte b,
byte c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static double |
median(double a,
double b,
double c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static float |
median(float a,
float b,
float c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static int |
median(int a,
int b,
int c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static long |
median(long a,
long b,
long c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static short |
median(short a,
short b,
short c)
Returns the median of 3 numbers: the 2nd number in the increasing order.
|
static byte |
min(byte a,
byte b)
An equivalent of
a <= b? a: b . |
static byte |
min(byte a,
byte b,
byte c)
Quicker equivalent of
min(a,min(b,c)) . |
static double |
min(double a,
double b)
An equivalent of
a <= b? a: b . |
static double |
min(double a,
double b,
double c)
Quicker equivalent of
min(a,min(b,c)) . |
static float |
min(float a,
float b)
An equivalent of
a <= b? a: b . |
static float |
min(float a,
float b,
float c)
Quicker equivalent of
min(a,min(b,c)) . |
static int |
min(int a,
int b)
An equivalent of
a <= b? a: b . |
static int |
min(int a,
int b,
int c)
Quicker equivalent of
min(a,min(b,c)) . |
static long |
min(long a,
long b)
An equivalent of
a <= b? a: b . |
static long |
min(long a,
long b,
long c)
Quicker equivalent of
min(a,min(b,c)) . |
static short |
min(short a,
short b)
An equivalent of
a <= b? a: b . |
static short |
min(short a,
short b,
short c)
Quicker equivalent of
min(a,min(b,c)) . |
static byte |
minu(byte a,
byte b)
Returns minimum of two unsigned 8-bit integer values.
|
static int |
minu(int a,
int b)
Returns minimum of two unsigned 32-bit integer values.
|
static long |
minu(long a,
long b)
Returns minimum of two unsigned 64-bit integer values.
|
static short |
minu(short a,
short b)
Returns minimum of two unsigned 16-bit integer values.
|
static double |
pow(double a,
double b)
An equivalent of
java.lang.Math.pow(a,b) |
static double |
rint(double a)
An equivalent of
java.lang.Math.rint(a) |
static long |
round(double a)
An equivalent of
java.lang.Math.round(a) call. |
static int |
round(float a)
An equivalent of
java.lang.Math.round(a) call. |
static double |
sin(double a)
An equivalent of
java.lang.Math.sin(a) |
static double |
sqr(double a)
An equivalent of
a * a |
static float |
sqr(float a)
An equivalent of
a * a |
static int |
sqr(int a)
An equivalent of
a * a |
static long |
sqr(long a)
An equivalent of
a * a |
static double |
sqrt(double a)
An equivalent of
java.lang.Math.sqrt(a) |
static double |
tan(double a)
An equivalent of
java.lang.Math.tan(a) |
static double |
toDegrees(double a)
An equivalent of
java.lang.Math.toDegrees(a) |
static double |
toRadians(double a)
An equivalent of
java.lang.Math.toRadians(a) |
public static final double E
java.lang.Math.E
public static final double PI
java.lang.Math.PI
public static int iround(double a)
(int)java.lang.Math.round(a)
call.a
- the argument(int)java.lang.Math.round(a)
callpublic static int round(float a)
java.lang.Math.round(a)
call.a
- the argumentjava.lang.Math.round(a)
callpublic static long round(double a)
java.lang.Math.round(a)
call.a
- the argumentjava.lang.Math.round(a)
callpublic static int abs(int a)
java.lang.Math.abs
method.a
- the argumentpublic static long abs(long a)
java.lang.Math.abs
method.a
- the argumentpublic static double abs(double a)
java.lang.Math.abs
method.a
- the argumentpublic static float abs(float a)
java.lang.Math.abs
method.a
- the argumentpublic static byte minu(byte a, byte b)
(a&0xFF) <= (b&0xFF)? a: b
a
- 1st argumentb
- 2nd argumentpublic static byte maxu(byte a, byte b)
(a&0xFF) >= (b&0xFF)? a: b
a
- 1st argumentb
- 2nd argumentpublic static short minu(short a, short b)
((char)a) <= ((char)b)? a: b
a
- 1st argumentb
- 2nd argumentpublic static short maxu(short a, short b)
((char)a) >= ((char)b)? a: b
a
- 1st argumentb
- 2nd argumentpublic static int minu(int a, int b)
(a^0x80000000) <= (b^0x80000000)? a: b
a
- 1st argumentb
- 2nd argumentpublic static int maxu(int a, int b)
(a^0x80000000) >= (b^0x80000000)? a: b
a
- 1st argumentb
- 2nd argumentpublic static long minu(long a, long b)
(a^0x8000000000000000L) <= (b^0x8000000000000000L)? a: b
a
- 1st argumentb
- 2nd argumentpublic static long maxu(long a, long b)
(a^0x8000000000000000L) >= (b^0x8000000000000000L)? a: b
a
- 1st argumentb
- 2nd argumentpublic static byte min(byte a, byte b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static byte max(byte a, byte b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static short min(short a, short b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static short max(short a, short b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static int min(int a, int b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static int max(int a, int b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static long min(long a, long b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static long max(long a, long b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static float min(float a, float b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static float max(float a, float b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static double min(double a, double b)
a <= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static double max(double a, double b)
a >= b? a: b
.a
- 1st argumentb
- 2nd argumentpublic static byte min(byte a, byte b, byte c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static byte max(byte a, byte b, byte c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static byte median(byte a, byte b, byte c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static short min(short a, short b, short c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static short max(short a, short b, short c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static short median(short a, short b, short c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static int min(int a, int b, int c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static int max(int a, int b, int c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static int median(int a, int b, int c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static long min(long a, long b, long c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static long max(long a, long b, long c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static long median(long a, long b, long c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static float min(float a, float b, float c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static float max(float a, float b, float c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static float median(float a, float b, float c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static double min(double a, double b, double c)
min(a,min(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static double max(double a, double b, double c)
max(a,max(b,c))
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static double median(double a, double b, double c)
a
"cut" by the range
min(b,c)...max(b,c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentpublic static boolean between(char a, char b, char c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("char" type)public static boolean between(byte a, byte b, byte c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("byte" type)public static boolean between(short a, short b, short c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("short" type)public static boolean between(int a, int b, int c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("int" type)public static boolean between(long a, long b, long c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("long" type)public static boolean between(float a, float b, float c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("float" type)public static boolean between(double a, double b, double c)
a >= min(b, c) && a <= max(b, c)
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumenttrue
if the a
value is between b
and c
values ("double" type)public static boolean between(float a, float b, float c, float epsilon)
a >= min(b, c) + epsilon && a <= max(b, c) - epsilon
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentepsilon
- permitted error of the checktrue
if the a
value is between b
and c
values with epsilon
error ("float" type)public static boolean between(double a, double b, double c, double epsilon)
a >= min(b, c) + epsilon && a <= max(b, c) - epsilon
.a
- 1st argumentb
- 2nd argumentc
- 3rd argumentepsilon
- permitted error of the checktrue
if the a
value is between b
and c
values with epsilon
error ("double" type)public static int sqr(int a)
a * a
a
- the argumentpublic static long sqr(long a)
a * a
a
- the argumentpublic static float sqr(float a)
a * a
a
- the argumentpublic static double sqr(double a)
a * a
a
- the argumentpublic static double sin(double a)
java.lang.Math.sin(a)
a
- the argumentjava.lang.Math.sin(a)
callpublic static double cos(double a)
java.lang.Math.cos(a)
a
- the argumentjava.lang.Math.cos(a)
callpublic static double tan(double a)
java.lang.Math.tan(a)
a
- the argumentjava.lang.Math.tan(a)
callpublic static double asin(double a)
java.lang.Math.asin(a)
a
- the argumentjava.lang.Math.asin(a)
callpublic static double acos(double a)
java.lang.Math.acos(a)
a
- the argumentjava.lang.Math.acos(a)
callpublic static double atan(double a)
java.lang.Math.atan(a)
a
- the argumentjava.lang.Math.atan(a)
callpublic static double toRadians(double a)
java.lang.Math.toRadians(a)
a
- the argumentjava.lang.Math.toRadians(a)
callpublic static double toDegrees(double a)
java.lang.Math.toDegrees(a)
a
- the argumentjava.lang.Math.toDegrees(a)
callpublic static double exp(double a)
java.lang.Math.exp(a)
a
- the argumentjava.lang.Math.exp(a)
callpublic static double log(double a)
java.lang.Math.log(a)
a
- the argumentjava.lang.Math.log(a)
callpublic static double sqrt(double a)
java.lang.Math.sqrt(a)
a
- the argumentjava.lang.Math.sqrt(a)
callpublic static double ceil(double a)
java.lang.Math.ceil(a)
a
- the argumentjava.lang.Math.ceil(a)
callpublic static double floor(double a)
java.lang.Math.floor(a)
a
- the argumentjava.lang.Math.floor(a)
callpublic static double rint(double a)
java.lang.Math.rint(a)
a
- the argumentjava.lang.Math.rint(a)
callpublic static double atan2(double a, double b)
java.lang.Math.atan2(a,b)
a
- 1st argumentb
- 2nd argumentjava.lang.Math.atan2(a,b)
callpublic static double IEEEremainder(double a, double b)
java.lang.Math.IEEEremainder(a,b)
a
- 1st argumentb
- 2nd argumentjava.lang.Math.IEEEremainder(a,b)
callpublic static double pow(double a, double b)
java.lang.Math.pow(a,b)
a
- 1st argumentb
- 2nd argumentjava.lang.Math.pow(a,b)
call