public final class NumberHelper extends Object
Modifier and Type | Field and Description |
---|---|
BiFunction<Number,Number,Number> |
add |
BiFunction<Number,Number,Integer> |
cmp |
BiFunction<Number,Number,Number> |
div |
BiFunction<Number,Number,Number> |
max |
BiFunction<Number,Number,Number> |
min |
BiFunction<Number,Number,Number> |
mul |
BiFunction<Number,Number,Number> |
sub |
Modifier and Type | Method and Description |
---|---|
static Number |
add(Number a,
Number b)
Adds two numbers returning the highest common number class between them.
|
static Integer |
compare(Number a,
Number b)
Compares two numbers.
|
static Number |
div(Number a,
Number b)
Divides two numbers returning the highest common number class between them calling
div(Number, Number, boolean) with a false . |
static Number |
div(Number a,
Number b,
boolean forceFloatingPoint)
Divides two numbers returning the highest common number class between them.
|
static Class<? extends Number> |
getHighestCommonNumberClass(boolean forceFloatingPoint,
Number... numbers) |
static Class<? extends Number> |
getHighestCommonNumberClass(Number... numbers) |
static Comparable |
max(Comparable a,
Comparable b)
Gets the larger number of the two provided returning the highest common number class between them.
|
static Number |
max(Number a,
Number b)
Gets the larger number of the two provided returning the highest common number class between them.
|
static Comparable |
min(Comparable a,
Comparable b)
Gets the smaller number of the two provided returning the highest common number class between them.
|
static Number |
min(Number a,
Number b)
Gets the smaller number of the two provided returning the highest common number class between them.
|
static Number |
mul(Number a,
Number b)
Multiplies two numbers returning the highest common number class between them.
|
static Number |
sub(Number a,
Number b)
Subtracts two numbers returning the highest common number class between them.
|
public final BiFunction<Number,Number,Number> add
public final BiFunction<Number,Number,Number> sub
public final BiFunction<Number,Number,Number> mul
public final BiFunction<Number,Number,Number> div
public final BiFunction<Number,Number,Number> min
public final BiFunction<Number,Number,Number> max
public final BiFunction<Number,Number,Integer> cmp
public static Class<? extends Number> getHighestCommonNumberClass(Number... numbers)
public static Class<? extends Number> getHighestCommonNumberClass(boolean forceFloatingPoint, Number... numbers)
public static Number add(Number a, Number b)
a = 1, b = 1 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null
a
- should be thought of as the seed to be modified by b
b
- the modifier to {code a}public static Number sub(Number a, Number b)
a = 1, b = 1 -> 0 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null
a
- should be thought of as the seed to be modified by b
b
- the modifier to {code a}public static Number mul(Number a, Number b)
a = 1, b = 2 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null
a
- should be thought of as the seed to be modified by b
b
- the modifier to {code a}public static Number div(Number a, Number b)
div(Number, Number, boolean)
with a false
.public static Number div(Number a, Number b, boolean forceFloatingPoint)
a = 4, b = 2 -> 2 a = null, b = 1 -> null a = 1, b = null -> 1 a = null, b = null -> null
a
- should be thought of as the seed to be modified by b
b
- the modifier to {code a}forceFloatingPoint
- when set to true
ensures that the return value is the highest common floating number classpublic static Number min(Number a, Number b)
a = 4, b = 2 -> 2 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null
public static Comparable min(Comparable a, Comparable b)
a = 4, b = 2 -> 2 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null
public static Number max(Number a, Number b)
a = 4, b = 2 -> 4 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null
public static Comparable max(Comparable a, Comparable b)
a = 4, b = 2 -> 4 a = null, b = 1 -> 1 a = 1, b = null -> 1 a = null, b = null -> null
Copyright © 2013–2022 Apache Software Foundation. All rights reserved.