Package net.solarnetwork.domain.datum
Interface DatumMathFunctions
- All Known Subinterfaces:
DatumExpressionRoot
- All Known Implementing Classes:
DatumSamplesExpressionRoot
public interface DatumMathFunctions
API for datum-related math helper functions.
- Since:
- 2.1
- Version:
- 1.1
- Author:
- matt
-
Method Summary
Modifier and TypeMethodDescriptiondefault BigIntegerApply a bitwise and operation to an integer number.default BigIntegerApply a bitwise and operation to an integer number that has had a not operation applied.default Numberavg(Collection<? extends Number> set) Compute the average (mean) of a group of numbers.default NumberRound positive numbers away from zero and negative numbers towards zero, to the nearest integer.default NumberRound positive numbers away from zero and negative numbers towards zero, to the nearest integer multiple of a specific significance.default BigDecimalReturn aBigDecimalfor a given value.default NumberRound a number towards zero to the nearest integer.default NumberRound a number towards zero to the nearest integer multiple of a specific significance.default NumberRound positive numbers towards zero and negative numbers away from zero, to the nearest integer multiple of a specific significance.default NumberRound positive numbers towards zero and negative numbers away from zero, to the nearest integer multiple of a specific significance.default BigIntegerReturn aBigIntegerfor a given value.default NumberReturn the maximum between two number values.default Numbermax(Collection<? extends Number> set) Find the maximum value in a group of numbers.default NumberReturn the minimum between two number values.default Numbermin(Collection<? extends Number> set) Find the minimum value in a group of numbers.default NumberRound a number to the nearest integer multiple of a specific significance.default NumberNarrow a number to the smallest possible number type that can exactly represent the given number.default NumberNarrow a number to at minimum a 16-bit value that can exactly represent the given number.default NumberNarrow a number to at minimum a 32-bit value that can exactly represent the given number.default NumberNarrow a number to at minimum a 64-bit value that can exactly represent the given number.default NumberNarrow a number to at minimum an 8-bit value that can exactly represent the given number.default BigIntegerApply a bitwise not operation to an integer number.default BigIntegerApply a bitwise or operation to an integer number.default NumberRound a number to the nearest integer.default NumberRound a number to a maximum number of decimal digits using theRoundingMode.HALF_UPmode.default NumberRound a number towards zero to a maximum number of decimal digits.default NumberRound a number away from zero to a maximum number of decimal digits.default BigIntegerApply a bitwise left-shift operation to an integer number.default BigIntegershiftRight(Number n, Number count) Apply a bitwise right-shift operation to an integer number.default Numbersum(Collection<? extends Number> set) Compute the sum a group of numbers.default booleanTest if a bit is set on an integer number.default NumberRound a number towards zero to the nearest integer.default NumberRound a number towards zero to the nearest integer multiple of a specific significance.default BigIntegerApply a bitwise xor operation to an integer number.
-
Method Details
-
and
Apply a bitwise and operation to an integer number.- Parameters:
n- the integer numbermask- the mask- Returns:
- the result of
(n & mask), ornas an integer ifmaskis null or null ifncannot be converted to an integer - Since:
- 1.1
-
not
Apply a bitwise not operation to an integer number.- Parameters:
n- the integer number- Returns:
- the result of
(~n), ornas an integer or null ifncannot be converted to an integer - Since:
- 1.1
-
andNot
Apply a bitwise and operation to an integer number that has had a not operation applied.- Parameters:
n- the integer numbermask- the mask- Returns:
- the result of
(n & ~mask), ornas an integer ifmaskis null or null ifncannot be converted to an integer - Since:
- 1.1
-
or
Apply a bitwise or operation to an integer number.- Parameters:
n- the integer numbermask- the mask- Returns:
- the result of
(n | mask), ornas an integer ifmaskis null or null ifncannot be converted to an integer - Since:
- 1.1
-
xor
Apply a bitwise xor operation to an integer number.- Parameters:
n- the integer numbermask- the mask- Returns:
- the result of
(n ^ mask), ornas an integer ifmaskis null or null ifncannot be converted to an integer - Since:
- 1.1
-
shiftRight
Apply a bitwise right-shift operation to an integer number.- Parameters:
n- the integer numbercount- the shift distance, in bits- Returns:
- the result of
(n >> count), ornas an integer ifcountis null or null ifncannot be converted to an integer - Since:
- 1.1
-
shiftLeft
Apply a bitwise left-shift operation to an integer number.- Parameters:
n- the integer numbercount- the shift distance, in bits- Returns:
- the result of
(n << count), ornas an integer ifcountis null or null ifncannot be converted to an integer - Since:
- 1.1
-
testBit
Test if a bit is set on an integer number.- Parameters:
n- the integer numberbit- the bit to test- Returns:
- the result of
((n & (1 << bit)) != 0), ornas an integer ifbitis null or null ifncannot be converted to an integer - Since:
- 1.1
-
decimal
Return aBigDecimalfor a given value.- Parameters:
value- the object to get as aBigDecimal- Returns:
- the decimal instance, or null if
valueis null or cannot be parsed as a decimal
-
integer
Return aBigIntegerfor a given value.- Parameters:
value- the object to get as aBigInteger- Returns:
- the integer instance, or null if
valueis null or cannot be parsed as an integer - Since:
- 1.1
-
min
Return the minimum between two number values.- Parameters:
n1- the first numbern2- the second number- Returns:
- the minimum number, or null if both arguments are null
-
max
Return the maximum between two number values.- Parameters:
n1- the first numbern2- the second number- Returns:
- the maximum number, or null if both arguments are null
-
ceil
Round positive numbers away from zero and negative numbers towards zero, to the nearest integer.- Parameters:
n- the number to round- Returns:
- the rounded number, or null if
nis null
-
ceil
Round positive numbers away from zero and negative numbers towards zero, to the nearest integer multiple of a specific significance.- Parameters:
n- the number to roundsignificance- the multiple factor to round to- Returns:
- the rounded number, or null if
norsignificanceare null
-
floor
Round positive numbers towards zero and negative numbers away from zero, to the nearest integer multiple of a specific significance.- Parameters:
n- the number to round- Returns:
- the rounded number, or null if
norsignificanceare null
-
floor
Round positive numbers towards zero and negative numbers away from zero, to the nearest integer multiple of a specific significance.- Parameters:
n- the number to roundsignificance- the multiple factor to round to- Returns:
- the rounded number, or null if
norsignificanceare null
-
up
Round a number towards zero to the nearest integer.This method is a shortcut for calling
roundUp(n, 0).- Parameters:
n- the number to round- Returns:
- the rounded number, or null if
nis null - See Also:
-
up
Round a number towards zero to the nearest integer multiple of a specific significance.- Parameters:
n- the number to roundsignificance- the multiple factor to round to- Returns:
- the rounded number, or null if
norsignificanceare null
-
down
Round a number towards zero to the nearest integer.This method is a shortcut for calling
roundDown(n, 0).- Parameters:
n- the number to round- Returns:
- the rounded number, or null if
nis null - See Also:
-
down
Round a number towards zero to the nearest integer multiple of a specific significance.This method rounds using the
RoundingMode.DOWNmode.- Parameters:
n- the number to roundsignificance- the multiple factor to round to- Returns:
- the rounded number, or null if
norsignificanceare null
-
mround
Round a number to the nearest integer multiple of a specific significance.- Parameters:
n- the number to roundsignificance- the multiple factor to round to- Returns:
- the rounded number, or null if
norsignificanceare null
-
round
Round a number to the nearest integer.This is a shortcut for calling
round(n, 0).- Parameters:
n- the number to round- Returns:
- the rounded number, or null if
nis null
-
round
Round a number to a maximum number of decimal digits using theRoundingMode.HALF_UPmode.- Parameters:
n- the number to rounddigits- the maximum number of decimal digits- Returns:
- the rounded number, or null if
nordigitsis null
-
roundUp
Round a number away from zero to a maximum number of decimal digits.- Parameters:
n- the number to rounddigits- the maximum number of decimal digits- Returns:
- the rounded number, or null if
nordigitsis null
-
roundDown
Round a number towards zero to a maximum number of decimal digits.- Parameters:
n- the number to rounddigits- the maximum number of decimal digits- Returns:
- the rounded number, or null if
nordigitsis null
-
narrow
Narrow a number to the smallest possible number type that can exactly represent the given number.If
ncannot be narrowed thennis returned. -
narrow8
Narrow a number to at minimum an 8-bit value that can exactly represent the given number.If
ncannot be narrowed thennis returned.- Parameters:
n- the number to narrow- Returns:
- the (possibly) narrowed number, or null if
nis null - Since:
- 1.1
-
narrow16
Narrow a number to at minimum a 16-bit value that can exactly represent the given number.If
ncannot be narrowed thennis returned.- Parameters:
n- the number to narrow- Returns:
- the (possibly) narrowed number, or null if
nis null - Since:
- 1.1
-
narrow32
Narrow a number to at minimum a 32-bit value that can exactly represent the given number.If
ncannot be narrowed thennis returned.- Parameters:
n- the number to narrow- Returns:
- the (possibly) narrowed number, or null if
nis null - Since:
- 1.1
-
narrow64
Narrow a number to at minimum a 64-bit value that can exactly represent the given number.If
ncannot be narrowed thennis returned.- Parameters:
n- the number to narrow- Returns:
- the (possibly) narrowed number, or null if
nis null - Since:
- 1.1
-
sum
Compute the sum a group of numbers.- Parameters:
set- the numbers to sum; if null then null will be returned- Returns:
- the sum of
set
-
avg
Compute the average (mean) of a group of numbers.- Parameters:
set- the numbers to average; if null or empty then null will be returned- Returns:
- the average of
set
-
max
Find the maximum value in a group of numbers.- Parameters:
set- the numbers to find the maximum in; if null or empty then null will be returned- Returns:
- the maximum of
set
-
min
Find the minimum value in a group of numbers.- Parameters:
set- the numbers to find the minimum in; if null or empty then null will be returned- Returns:
- the minimum of
set
-