public class NumberUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static @PolyNull Double |
add(@PolyNull Double a,
@PolyNull Double b)
Returns the sum of two numbers, or null if either is null.
|
static DecimalFormat |
decimalFormat(String pattern)
Creates a format.
|
static @Nullable Double |
divide(@Nullable Double a,
@Nullable Double b)
Returns the quotient of two numbers,
or null if either is null or the divisor is zero.
|
static NumberFormat |
getApproxFormatter(boolean isFloat) |
static BigInteger |
getMaxUnscaled(int precision) |
static BigInteger |
getMinUnscaled(int precision) |
static boolean |
isValidDecimal(BigDecimal bd)
Returns whether a
BigDecimal is a valid Farrago decimal. |
static @PolyNull Double |
max(@PolyNull Double a,
@PolyNull Double b)
Like
Math.max(int, int) but null safe;
returns the greater of two numbers,
or null if either is null. |
static @PolyNull Double |
min(@PolyNull Double a,
@PolyNull Double b)
Like
Math.min(int, int) but null safe;
returns the lesser of two numbers,
ignoring numbers that are null,
or null if both are null. |
static @PolyNull Double |
multiply(@PolyNull Double a,
@PolyNull Double b)
Returns the product of two numbers,
or null if either is null.
|
static BigInteger |
powTen(int exponent) |
static @PolyNull BigDecimal |
rescaleBigDecimal(@PolyNull BigDecimal bd,
int scale)
Sets the scale of a BigDecimal
bd if it is not null;
always returns bd. |
static long |
round(double d) |
static @PolyNull Double |
subtract(@PolyNull Double a,
@PolyNull Double b)
Returns the difference of two numbers,
or null if either is null.
|
static @PolyNull BigDecimal |
toBigDecimal(@PolyNull Number number)
Converts a number to a BigDecimal with the same value;
returns null if and only if the number is null.
|
static BigDecimal |
toBigDecimal(Number number,
int scale) |
public static DecimalFormat decimalFormat(String pattern)
public static BigInteger powTen(int exponent)
public static BigInteger getMaxUnscaled(int precision)
public static BigInteger getMinUnscaled(int precision)
public static @PolyNull BigDecimal rescaleBigDecimal(@PolyNull BigDecimal bd, int scale)
bd if it is not null;
always returns bd.public static BigDecimal toBigDecimal(Number number, int scale)
public static @PolyNull BigDecimal toBigDecimal(@PolyNull Number number)
public static boolean isValidDecimal(BigDecimal bd)
BigDecimal is a valid Farrago decimal. If a
BigDecimal's unscaled value overflows a long, then it is not a valid
Farrago decimal.public static NumberFormat getApproxFormatter(boolean isFloat)
public static long round(double d)
public static @PolyNull Double add(@PolyNull Double a, @PolyNull Double b)
public static @PolyNull Double subtract(@PolyNull Double a, @PolyNull Double b)
public static @Nullable Double divide(@Nullable Double a, @Nullable Double b)
public static @PolyNull Double multiply(@PolyNull Double a, @PolyNull Double b)
public static @PolyNull Double min(@PolyNull Double a, @PolyNull Double b)
Math.min(int, int) but null safe;
returns the lesser of two numbers,
ignoring numbers that are null,
or null if both are null.public static @PolyNull Double max(@PolyNull Double a, @PolyNull Double b)
Math.max(int, int) but null safe;
returns the greater of two numbers,
or null if either is null.Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.