Class NumberUtil
java.lang.Object
org.nuiton.util.NumberUtil
- Since:
- 3.0
- Author:
- Kevin Morin - morin@codelutin.com
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final MathContextprotected static final MathContextprotected static final MathContextprotected static final MathContextprotected static final MathContextstatic final com.google.common.base.Predicate<Float> static final com.google.common.base.Predicate<Float> static final com.google.common.base.Predicate<Float> static final com.google.common.base.Predicate<Float> static final com.google.common.base.Predicate<Float> static final com.google.common.base.Predicate<Integer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]divideAndEnsureSum(int divisor, int dividend) Divide the divisor by the dividend.static Floatround(Float number, MathContext mc) static FloatroundFiveDigits(Float number) static FloatroundFourDigits(Float number) static FloatroundNDigits(Float number, int digits) static FloatroundOneDigit(Float number) static FloatroundThreeDigits(Float number) static FloatroundTwoDigits(Float number)
-
Field Details
-
NULL_OR_ZERO_INTEGER
-
NULL_OR_ZERO_FLOAT_ONE_DIGIT
-
NULL_OR_ZERO_FLOAT_TWO_DIGITS
-
NULL_OR_ZERO_FLOAT_THREE_DIGITS
-
NULL_OR_ZERO_FLOAT_FOUR_DIGITS
-
NULL_OR_ZERO_FLOAT_FIVE_DIGITS
-
mc1Digit
-
mc2Digits
-
mc3Digits
-
mc4Digits
-
mc5Digits
-
-
Constructor Details
-
NumberUtil
public NumberUtil()
-
-
Method Details
-
divideAndEnsureSum
public static int[] divideAndEnsureSum(int divisor, int dividend) Divide the divisor by the dividend. Returns an array containing the quotients rounded up or down to ensure the sum of the quotients equals the divisor.e.g. divideAndEnsureSum(100, 3) returns {34, 33, 33}
- Parameters:
divisor- the divisordividend- the dividend- Returns:
- an array whose length equals dividend
-
roundOneDigit
-
roundTwoDigits
-
roundThreeDigits
-
roundFourDigits
-
roundFiveDigits
-
roundNDigits
-
round
-