/** * Divide two Numbers. * * Note: Method name different from 'divide' to avoid collision with BigInteger method that has * different semantics. We want a BigDecimal result rather than a BigInteger. * * @param left a Number * @param right another Number * @return a Number resulting of the divide operation */ public static Number div(Number left, Number right) { return NumberMath.divide(left, right); }
/** * Multiply two Numbers. * * @param left a Number * @param right another Number * @return the multiplication of both */ //Note: This method is NOT called if left AND right are both BigIntegers or BigDecimals because //those classes implement a method with a better exact match. public static Number multiply(Number left, Number right) { return NumberMath.multiply(left, right); }
/** * Add two numbers and return the result. * * @param left a Number * @param right another Number to add * @return the addition of both Numbers */ public static Number plus(Number left, Number right) { return NumberMath.add(left, right); }
/** * Indicates progress as a percentage for the given number and total. * * @param number The number * @param total The total */ @SuppressWarnings("MagicNumber") @Override public void indicateProgressPercentage(long number, long total) { verifySystemOut(); progressIndicatorActive = true; String currMsg = lastMessage; try { int percentage = Math.round(NumberMath.multiply(NumberMath.divide(number, total), 100).floatValue()); if (!isAnsiEnabled()) { out.print(".."); out.print(percentage + '%'); } else { updateStatus(currMsg + ' ' + percentage + '%'); } } finally { lastMessage = currMsg; } }
switch(type) { case PLUS: result = NumberMath.add(left, right); break; case MINUS: result = NumberMath.subtract(left, right); break; case MULTIPLY: result = NumberMath.multiply(left, right); break; case DIVIDE: result = NumberMath.divide(left, right); break; case LEFT_SHIFT: result = NumberMath.leftShift(left, right); break; case RIGHT_SHIFT: result = NumberMath.rightShift(left, right); break; case RIGHT_SHIFT_UNSIGNED: result = NumberMath.rightShiftUnsigned(left, right); break; case BITWISE_AND: result = NumberMath.and(left, right); break; case BITWISE_OR: result = NumberMath.or(left, right); break; case BITWISE_XOR:
/** * Performs a division modulus operation. Called by the '%' operator. * * @param left a Number * @param right another Number to mod * @return the modulus result * @since 1.0 */ public static Number mod(Number left, Number right) { return NumberMath.mod(left, right); }
/** * Subtraction of two Numbers. * * @param left a Number * @param right another Number to subtract to the first one * @return the subtraction */ public static Number minus(Number left, Number right) { return NumberMath.subtract(left, right); }
/** * Bitwise AND together two Numbers. * * @param left a Number * @param right another Number to bitwise AND * @return the bitwise AND of both Numbers * @since 1.0 */ public static Number and(Number left, Number right) { return NumberMath.and(left, right); }
/** * Bitwise OR together two numbers. * * @param left a Number * @param right another Number to bitwise OR * @return the bitwise OR of both Numbers * @since 1.0 */ public static Number or(Number left, Number right) { return NumberMath.or(left, right); }
/** * Bitwise XOR together two Numbers. Called when the '^' operator is used. * * @param left a Number * @param right another Number to bitwse XOR * @return the bitwise XOR of both Numbers * @since 1.0 */ public static Number xor(Number left, Number right) { return NumberMath.xor(left, right); }
public Object invoke(Object receiver, Object arg) { return math.addImpl((Number) receiver, (Number) arg); } };
/** * Performs a division modulus operation. Called by the '%' operator. * * @param left a Number * @param right another Number to mod * @return the modulus result * @since 1.0 */ public static Number mod(Number left, Number right) { return NumberMath.mod(left, right); }
public Object invoke(Object object, Object[] arguments) { return NumberMath.subtract((Number) object, (Number) arguments[0]); }
/** * Bitwise AND together two Numbers. * * @param left a Number * @param right another Number to bitwise AND * @return the bitwise AND of both Numbers * @since 1.0 */ public static Number and(Number left, Number right) { return NumberMath.and(left, right); }
/** * Bitwise OR together two numbers. * * @param left a Number * @param right another Number to bitwise OR * @return the bitwise OR of both Numbers * @since 1.0 */ public static Number or(Number left, Number right) { return NumberMath.or(left, right); }
/** * Bitwise XOR together two Numbers. Called when the '|' operator is used. * * @param left a Number * @param right another Number to bitwse XOR * @return the bitwise XOR of both Numbers * @since 1.0 */ public static Number xor(Number left, Number right) { return NumberMath.xor(left, right); }