Package org.apache.calcite.util
Class NumberUtil
java.lang.Object
org.apache.calcite.util.NumberUtil
Utility functions for working with numbers.
- 
Method SummaryModifier and TypeMethodDescriptionstatic @PolyNull DoubleReturns the sum of two numbers, or null if either is null.static DecimalFormatdecimalFormat(String pattern) Creates a format.static @Nullable DoubleReturns the quotient of two numbers, or null if either is null or the divisor is zero.static NumberFormatgetApproxFormatter(boolean isFloat) static BigIntegergetMaxUnscaled(int precision) static BigIntegergetMinUnscaled(int precision) static booleanReturns whether aBigDecimalis a valid Farrago decimal.static @PolyNull DoubleLikeMath.max(int, int)but null safe; returns the greater of two numbers, or null if either is null.static @PolyNull DoubleLikeMath.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 DoubleReturns the product of two numbers, or null if either is null.static BigIntegerpowTen(int exponent) static @PolyNull BigDecimalrescaleBigDecimal(@PolyNull BigDecimal bd, int scale) Sets the scale of a BigDecimalbdif it is not null; always returnsbd.static longround(double d) static @PolyNull DoubleReturns the difference of two numbers, or null if either is null.static @PolyNull BigDecimaltoBigDecimal(@PolyNull Number number) Converts a number to a BigDecimal with the same value; returns null if and only if the number is null.static BigDecimaltoBigDecimal(Number number, int scale) 
- 
Method Details- 
decimalFormatCreates a format. Locale-independent.
- 
powTen
- 
getMaxUnscaled
- 
getMinUnscaled
- 
rescaleBigDecimalSets the scale of a BigDecimalbdif it is not null; always returnsbd.
- 
toBigDecimal
- 
toBigDecimalConverts a number to a BigDecimal with the same value; returns null if and only if the number is null.
- 
isValidDecimalReturns whether aBigDecimalis a valid Farrago decimal. If a BigDecimal's unscaled value overflows a long, then it is not a valid Farrago decimal.
- 
getApproxFormatter
- 
roundpublic static long round(double d) 
- 
addReturns the sum of two numbers, or null if either is null.
- 
subtractReturns the difference of two numbers, or null if either is null.
- 
divideReturns the quotient of two numbers, or null if either is null or the divisor is zero.
- 
multiplyReturns the product of two numbers, or null if either is null.
- 
minLikeMath.min(int, int)but null safe; returns the lesser of two numbers, ignoring numbers that are null, or null if both are null.
- 
maxLikeMath.max(int, int)but null safe; returns the greater of two numbers, or null if either is null.
 
-