Returns a {@code BigDecimal} whose value is {@code (this -
subtrahend)}, and whose scale is {@code max(this.scale(),
subtrahend.scale())}.

@param  subtrahend value to be subtracted from this {@code BigDecimal}.
@return {@code this - subtrahend}
333250
public BigDecimal subtract(BigDecimal subtrahend) {
        if (this.intCompact != INFLATED) {
            if ((subtrahend.intCompact != INFLATED)) {
                return add(this.intCompact, this.scale, -subtrahend.intCompact, subtrahend.scale);
            } else {
                return add(this.intCompact, this.scale, subtrahend.intVal.negate(), subtrahend.scale);
            }
        } else {
            if ((subtrahend.intCompact != INFLATED)) {
                // Pair of subtrahend values given before pair of
                // values from this BigDecimal to avoid need for
                // method overloading on the specialized add method
                return add(-subtrahend.intCompact, subtrahend.scale, this.intVal, this.scale);
            } else {
                return add(this.intVal, this.scale, subtrahend.intVal.negate(), subtrahend.scale);
            }
        }
    }
532922
public T divide(T divisor) {
        if (divisor == null) {
            throw new IllegalArgumentException("invalid (null) divisor");
        }
        BigDecimal quotient = this.value.divide(divisor.value, ROUND_BEHAVIOR);

        return newInstance(quotient, this.value.scale());
    }
409499
public function subtract($amount, $subtrahend)
    {
        return (string) Number::fromString(bcsub($amount, $subtrahend, $this->scale));
    }
325751
public function subtract(self $subtrahend)
    {
        $this->assertSameCurrency($subtrahend);

        return new self($this->amount - $subtrahend->amount, $this->currency);
    }
706589
public BigDecimal getGuesses()
    {
        final Double guesses_tmp = Math.pow(2, getEntropy());
        return new BigDecimal(guesses_tmp.isInfinite() ? Double.MAX_VALUE : guesses_tmp).setScale(0, RoundingMode.HALF_UP);
    }
640461
public static BigFloat acoth(BigFloat x) {
		return x.context.valueOf(BigDecimalMath.acoth(x.value, x.context.mathContext));
	}
869022
public static BigDecimal asinUsingNewton(BigDecimal x, MathContext mathContext) {
		if (x.compareTo(ONE) > 0) {
			throw new ArithmeticException("Illegal asin(x) for x > 1: x = " + x);
		}
		if (x.compareTo(MINUS_ONE) < 0) {
			throw new ArithmeticException("Illegal asin(x) for x < -1: x = " + x);
		}
		
		if (x.signum() == -1) {
			return asinUsingNewton(x.negate(), mathContext).negate();
		}

		int maxPrecision = mathContext.getPrecision() + 4;

		BigDecimal acceptableError = ONE.movePointLeft(mathContext.getPrecision() + 1);
		MathContext maxMathContext = new MathContext(maxPrecision, mathContext.getRoundingMode());
		
		if (x.compareTo(BigDecimal.valueOf(0.707107)) >= 0) {
			BigDecimal xTransformed = BigDecimalMath.sqrt(ONE.subtract(x.multiply(x, maxMathContext), maxMathContext), maxMathContext);
			return acosUsingNewton(xTransformed, mathContext);
		}

		BigDecimal denominator = BigDecimalMath.cos(x, maxMathContext);

		BigDecimal result = BigDecimal.valueOf(Math.asin(x.doubleValue()));
		int adaptivePrecision = 17;
		BigDecimal step;
		
		do {
			adaptivePrecision = adaptivePrecision * 3;
			if (adaptivePrecision > maxPrecision) {
				adaptivePrecision = maxPrecision;
			}
			MathContext mc = new MathContext(adaptivePrecision, mathContext.getRoundingMode());

			BigDecimal nominator = BigDecimalMath.sin(result, mc).subtract(x, mc); 
			step = nominator.divide(denominator, mc);
			result = result.subtract(step, mc);
//			System.out.println(BigDecimalMath.exponent(step) + " : " + result);
		} while (step.abs().compareTo(acceptableError) > 0);

		return result.round(mathContext);
	}
540423
public BigComplex subtract(BigComplex value) {
		return valueOf(
				re.subtract(value.re),
				im.subtract(value.im));
	}
879736
public BigDecimal getBigDecimal(String name) {
        Object found = content.get(name);
        if (found == null) {
            return null;
        } else if (found instanceof Double) {
            return new BigDecimal((Double) found);
        }
        return (BigDecimal) found;
    }
267470
private Double scale(Double value, Double min, Double max) {
        if(min.equals(max)) {
            if(value>max) {
                return 1.0;
            }
            else if(value==max && value!=0.0) {
                return 1.0;
            }
            else {
                return 0.0;
            }
        }
        else {
            return (value-min)/(max-min);
        }
    }
239152
public synchronized BigDecimal getBigDecimal(int parameterIndex,
            int scale) throws SQLException {

        if (scale < 0) {
            throw Util.outOfRangeArgument();
        }

        // boucherb@users 20020502 - added conversion
        BigDecimal bd = (BigDecimal) getColumnInType(parameterIndex,
            Type.SQL_DECIMAL);

        if (bd != null) {
            bd = bd.setScale(scale, BigDecimal.ROUND_DOWN);
        }

        return bd;
    }
31196
public static BigDecimal mod(EvaluationContext ctx, Object number, Object divisor) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        BigDecimal _divisor = Conversions.toDecimal(divisor, ctx);
        return _number.subtract(_divisor.multiply(new BigDecimal(_int(ctx, _number.divide(_divisor, 10, RoundingMode.HALF_UP)))));
    }
553487
public static double scaleValue(double value, int decimals) {
    BigDecimal bd = BigDecimal.valueOf(value);
    return bd.setScale(decimals, RoundingMode.HALF_UP).doubleValue();
  }
196436
public BigDecimal getValueAsBigDecimal() {
        String value = (String) $(valueBoxBase.getElement()).val();
        if (value != null && !value.isEmpty()) {
            return new BigDecimal(value);
        } else {
            return null;
        }
    }
211855
public static Function<Object,BigDecimal> bigDecimal(final String methodName, final Object... optionalParameters) {
        return methodForBigDecimal(methodName, optionalParameters);
    }
995596
public static final Function<BigDecimal,BigDecimal> roundBigDecimal(final int scale, final RoundingMode roundingMode) {
        return new RoundBigDecimal(scale, roundingMode);
    }
1170572
public BigDecimal getBigDecimal(int columnIndex,
                                    int scale) throws SQLException {

        if (scale < 0) {
            throw Util.outOfRangeArgument();
        }

        // boucherb@users 20020502 - added conversion
        BigDecimal bd = (BigDecimal) getColumnInType(columnIndex,
            Type.SQL_DECIMAL);

        if (bd != null) {
            bd = bd.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
        }

        return bd;
    }