public class NumberUtil extends Object
Modifier and Type | Field and Description |
---|---|
protected static MathContext |
mc1Digit |
protected static MathContext |
mc2Digits |
protected static MathContext |
mc3Digits |
protected static MathContext |
mc4Digits |
protected static MathContext |
mc5Digits |
static com.google.common.base.Predicate<Float> |
NULL_OR_ZERO_FLOAT_FIVE_DIGITS |
static com.google.common.base.Predicate<Float> |
NULL_OR_ZERO_FLOAT_FOUR_DIGITS |
static com.google.common.base.Predicate<Float> |
NULL_OR_ZERO_FLOAT_ONE_DIGIT |
static com.google.common.base.Predicate<Float> |
NULL_OR_ZERO_FLOAT_THREE_DIGITS |
static com.google.common.base.Predicate<Float> |
NULL_OR_ZERO_FLOAT_TWO_DIGITS |
static com.google.common.base.Predicate<Integer> |
NULL_OR_ZERO_INTEGER |
Constructor and Description |
---|
NumberUtil() |
Modifier and Type | Method and Description |
---|---|
static int[] |
divideAndEnsureSum(int divisor,
int dividend)
Divide the divisor by the dividend.
|
static Float |
round(Float number,
MathContext mc) |
static Float |
roundFiveDigits(Float number) |
static Float |
roundFourDigits(Float number) |
static Float |
roundNDigits(Float number,
int digits) |
static Float |
roundOneDigit(Float number) |
static Float |
roundThreeDigits(Float number) |
static Float |
roundTwoDigits(Float number) |
public static final com.google.common.base.Predicate<Integer> NULL_OR_ZERO_INTEGER
public static final com.google.common.base.Predicate<Float> NULL_OR_ZERO_FLOAT_ONE_DIGIT
public static final com.google.common.base.Predicate<Float> NULL_OR_ZERO_FLOAT_TWO_DIGITS
public static final com.google.common.base.Predicate<Float> NULL_OR_ZERO_FLOAT_THREE_DIGITS
public static final com.google.common.base.Predicate<Float> NULL_OR_ZERO_FLOAT_FOUR_DIGITS
public static final com.google.common.base.Predicate<Float> NULL_OR_ZERO_FLOAT_FIVE_DIGITS
protected static final MathContext mc1Digit
protected static final MathContext mc2Digits
protected static final MathContext mc3Digits
protected static final MathContext mc4Digits
protected static final MathContext mc5Digits
public static int[] divideAndEnsureSum(int divisor, int dividend)
e.g. divideAndEnsureSum(100, 3) returns {34, 33, 33}
divisor
- the divisordividend
- the dividendpublic static Float round(Float number, MathContext mc)
Copyright © 2004–2020 CodeLutin. All rights reserved.