public class N extends Object
The namespace under which number relevant structures, functions and logics are defined.
Alias of NumberUtil
| Modifier and Type | Class and Description |
|---|---|
static class |
N._FloatRequire |
static class |
N._IntRequire |
static class |
N.ByteRangeStep |
static class |
N.Comparator |
static class |
N.Coordinate2D |
static class |
N.Dimension |
static class |
N.F |
static class |
N.IntRangeStep |
static class |
N.LongRangeStep |
static class |
N.Num<T extends Number> |
static class |
N.Op |
static class |
N.Pair |
static class |
N.RangeStep<T extends Number> |
static class |
N.ShortRangeStep |
static class |
N.Type |
static class |
N.WH |
static class |
N.XY |
| Modifier and Type | Field and Description |
|---|---|
static double |
E
The
double value that is closer than any other to e, the base of the natural logarithms. |
static byte[] |
EMPTY_BYTE_ARRAY
An empty
byte[] |
static double[] |
EMPTY_DOUBLE_ARRAY
An empty
double[] |
static float[] |
EMPTY_FLOAT_ARRAY
An empty
float[] |
static int[] |
EMPTY_INT_ARRAY
An empty
int[] |
static long[] |
EMPTY_LONG_ARRAY
An empty
long[] |
static short[] |
EMPTY_SHORT_ARRAY
An empty
short[] |
static List<Class<? extends Number>> |
NUMBER_CLASSES |
static double |
PI
The
double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. |
static int[] |
POW_OF_TEN_INT |
static long[] |
POW_OF_TEN_LONG |
| Modifier and Type | Method and Description |
|---|---|
static double |
abs(double a) |
static float |
abs(float a) |
static int |
abs(int a) |
static long |
abs(long a) |
static double |
cbrt(double a) |
static double |
ceil(double a) |
static N.WH |
dimension(int width,
int height) |
static boolean |
eq(Number a,
Number b) |
static double |
exp(double a) |
static double |
floor(double a) |
static boolean |
gt(Number a,
Number b) |
static boolean |
isAlpha(double n)
Check if a double
d is alpha - Image alpha float range is 0.0f to 1.0f inclusive. |
static boolean |
isAlpha(float f)
Check if a float
f is alpha - Image alpha float range is 0.0f to 1.0f inclusive. |
static boolean |
isInt(String s)
Check if a string
s represent an int or long |
static boolean |
isInt(String s,
int radix)
Check if a string
s represent an int or long as per radix specified |
static boolean |
isNegative(BigDecimal number)
Check if a
BigDecimal is negative |
static boolean |
isNegative(BigInteger number)
Check if a
BigInteger is negative |
static boolean |
isNumeric(String s)
Check if a String
s is numeric string |
static boolean |
isPerfectSquare(long n)
Check if a long is a perfect square number.
|
static boolean |
isPositive(BigDecimal number)
Check if a
BigDecimal is positive |
static boolean |
isPositive(BigInteger number)
Check if a
BigInteger is positive |
static double |
log(double a) |
static double |
log10(double a) |
static boolean |
lt(Number a,
Number b) |
static double |
max(double a,
double b) |
static float |
max(float a,
float b) |
static int |
max(int a,
int b) |
static long |
max(long a,
long b) |
static double |
min(double a,
double b) |
static float |
min(float a,
float b) |
static int |
min(int a,
int b) |
static long |
min(long a,
long b) |
static boolean |
neq(Number a,
Number b) |
static N.Num |
num(Number number) |
static N.Num |
num(String s) |
static N.Pair |
Pair(Integer a,
Integer b) |
static double |
pow(double a,
double b) |
static int |
powOfTen(int e) |
static long |
powOfTenLong(int e) |
static double |
randDouble() |
static double |
randDoubleWithSymbol() |
static float |
randFloat() |
static float |
randFloatWithSymbol() |
static int |
randInt() |
static int |
randInt(int max) |
static int |
randInt(int min,
int max) |
static int |
randIntWithSymbol() |
static int |
randIntWithSymbol(int max) |
static long |
randLong() |
static long |
randLong(long max) |
static long |
randLongWithSymbol() |
static N._IntRequire |
require(int n) |
static double |
requireAlpha(double n) |
static float |
requireAlpha(float n)
Return a float value if it
isAlpha(float) or raise an IllegalArgumentException if not. |
static float |
requireAlpha(float n,
String errorTemplate,
Object... errorArgs)
Return a float value if it
isAlpha(float) or raise an IllegalArgumentException with given error message specified if not. |
static double |
requireNegative(double n) |
static float |
requireNegative(float n) |
static int |
requireNegative(int n) |
static int |
requireNegative(int n,
String errorTemplate,
Object... errorArgs) |
static double |
requireNonNegative(double n) |
static float |
requireNonNegative(float n) |
static int |
requireNonNegative(int n) |
static int |
requireNonNegative(int n,
String errorTemplate,
Object... errorArgs) |
static double |
requireNotNaN(double d) |
static float |
requireNotNaN(float f) |
static double |
requirePositive(double n) |
static float |
requirePositive(float n)
Return a positive float
n. |
static float |
requirePositive(float n,
String errorTemplate,
Object... errorArgs)
Return a positive float
n. |
static int |
requirePositive(int n) |
static int |
requirePositive(int n,
String errorTemplate,
Object... errorArgs) |
static long |
round(double a) |
static double |
round(double value,
int places) |
static int |
round(float a) |
static float |
round(float value,
int places) |
static double |
secureRandDouble() |
static double |
secureRandDoubleWithSymbol() |
static float |
secureRandFloat() |
static float |
secureRandFloatWithSymbol() |
static int |
secureRandInt()
The secure version of
randInt() |
static int |
secureRandInt(int max) |
static int |
secureRandInt(int min,
int max) |
static int |
secureRandIntWithSymbol() |
static int |
secureRandIntWithSymbol(int max) |
static long |
secureRandLong() |
static long |
secureRandLongWithSymbol() |
static int |
sign(Number number) |
static double |
sqrt(double a) |
static N.WH |
wh(int w,
int h) |
static N.XY |
xy(int x,
int y) |
public static final byte[] EMPTY_BYTE_ARRAY
An empty byte[]
public static final short[] EMPTY_SHORT_ARRAY
An empty short[]
public static final int[] EMPTY_INT_ARRAY
An empty int[]
public static final float[] EMPTY_FLOAT_ARRAY
An empty float[]
public static final long[] EMPTY_LONG_ARRAY
An empty long[]
public static final double[] EMPTY_DOUBLE_ARRAY
An empty double[]
public static final int[] POW_OF_TEN_INT
public static final long[] POW_OF_TEN_LONG
public static final double E
The double value that is closer than any other to e, the base of the natural logarithms.
public static final double PI
The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.
public static N.XY xy(int x, int y)
public static N.WH dimension(int width, int height)
public static N.WH wh(int w, int h)
public static N._IntRequire require(int n)
public static int requirePositive(int n)
public static int requireNonNegative(int n)
public static int requireNonNegative(int n,
String errorTemplate,
Object... errorArgs)
public static int requireNegative(int n)
public static float requirePositive(float n)
Return a positive float n. If the passed in n is 0 or negative then it raised a IllegalArgumentException.
n - a float number.n if it is greater than 0.0f.IllegalArgumentException - if n is not greater than 0.0f.public static float requirePositive(float n,
String errorTemplate,
Object... errorArgs)
Return a positive float n. If the passed in n is 0 or negative then it raised a IllegalArgumentException using the error template and arguments provided.
n - a float number.errorTemplate - the error message templateerrorArgs - the error message argumentsn if it is greater than 0.0f.IllegalArgumentException - if n is not greater than 0.0f.public static boolean isAlpha(float f)
Check if a float f is alpha - Image alpha float range is 0.0f to 1.0f inclusive.
f - the float number to be tested.true if f fall into alpha range or false otherwisepublic static float requireAlpha(float n)
Return a float value if it isAlpha(float) or raise an IllegalArgumentException if not.
n - the float number to be testedIllegalArgumentException - if the number is beyond the rangepublic static float requireAlpha(float n,
String errorTemplate,
Object... errorArgs)
Return a float value if it isAlpha(float) or raise an IllegalArgumentException with given error message specified if not.
n - a float number.errorTemplate - the error message templateerrorArgs - the error message argumentsn if it is greater than 0.0f.IllegalArgumentException - if n is not greater than 0.0f.public static float requireNotNaN(float f)
public static float requireNonNegative(float n)
public static float requireNegative(float n)
public static boolean isAlpha(double n)
Check if a double d is alpha - Image alpha float range is 0.0f to 1.0f inclusive.
n - the float number to be tested.true if f fall into alpha range or false otherwisepublic static double requireAlpha(double n)
public static double requirePositive(double n)
public static double requireNotNaN(double d)
public static double requireNonNegative(double n)
public static double requireNegative(double n)
public static double exp(double a)
public static double log(double a)
public static double log10(double a)
public static double sqrt(double a)
public static double cbrt(double a)
public static double ceil(double a)
public static double floor(double a)
public static double pow(double a,
double b)
public static int powOfTen(int e)
public static long powOfTenLong(int e)
public static int round(float a)
public static float round(float value,
int places)
public static long round(double a)
public static double round(double value,
int places)
public static final boolean isPerfectSquare(long n)
Check if a long is a perfect square number.
A perfect square number is an integer whose square root is also an integer
n - a numbertrue if the number is perfect square numberpublic static boolean isInt(String s)
Check if a string s represent an int or long
s - the stringtrue if s represents an int or false otherwisepublic static boolean isInt(String s, int radix)
Check if a string s represent an int or long as per radix specified
s - the stringradix - the radixtrue if s represents an int or false otherwisepublic static boolean isNumeric(String s)
Check if a String s is numeric string
s - the stringtrue if s is numeric or false otherwisepublic static boolean isNegative(BigDecimal number)
Check if a BigDecimal is negative
number - the number to be testedtrue if the number specified is negative or false otherwisepublic static boolean isNegative(BigInteger number)
Check if a BigInteger is negative
number - the number to be testedtrue if the number specified is negative or false otherwisepublic static boolean isPositive(BigDecimal number)
Check if a BigDecimal is positive
number - the number to be testedtrue if the number specified is positive or false otherwisepublic static boolean isPositive(BigInteger number)
Check if a BigInteger is positive
number - the number to be testedtrue if the number specified is positive or false otherwisepublic static int randInt()
Random.nextInt()public static int secureRandInt()
The secure version of randInt()
public static int randIntWithSymbol()
public static int secureRandIntWithSymbol()
public static int randInt(int max)
max - the max limit (exclusive) of the number generatedRandom.nextInt(int)public static int randInt(int min,
int max)
public static int secureRandInt(int max)
public static int secureRandInt(int min,
int max)
public static int randIntWithSymbol(int max)
public static int secureRandIntWithSymbol(int max)
public static float randFloat()
public static float secureRandFloat()
public static float randFloatWithSymbol()
public static float secureRandFloatWithSymbol()
public static long randLong()
public static long randLong(long max)
public static long secureRandLong()
public static long randLongWithSymbol()
public static long secureRandLongWithSymbol()
public static double randDouble()
Random.nextDouble()public static double secureRandDouble()
public static double randDoubleWithSymbol()
public static double secureRandDoubleWithSymbol()
public static int abs(int a)
public static long abs(long a)
public static float abs(float a)
public static double abs(double a)
public static int max(int a,
int b)
public static long max(long a,
long b)
public static float max(float a,
float b)
public static double max(double a,
double b)
public static int min(int a,
int b)
public static long min(long a,
long b)
public static float min(float a,
float b)
public static double min(double a,
double b)
public static int sign(Number number)
Copyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.