Truncate the value

@param number a BigDecimal
@param precision the number of decimal places to keep
@return a BigDecimal truncated to the number of decimal places specified by precision
@see #trunc(java.math.BigDecimal)
@since 2.5.0
507352
public static BigDecimal trunc(BigDecimal number, int precision) {
        return number.setScale(precision, RoundingMode.DOWN);
    }
688740
public static Decimal fromBigDecimal(BigDecimal bd, int precision, int scale) {
		bd = bd.setScale(scale, RoundingMode.HALF_UP);
		if (bd.precision() > precision) {
			return null;
		}

		long longVal = -1;
		if (precision <= MAX_COMPACT_PRECISION) {
			longVal = bd.movePointRight(scale).longValueExact();
		}
		return new Decimal(precision, scale, longVal, bd);
	}
40813
public function compute(DecimalNumber $number, $precision, $roundingMode)
    {
        switch ($roundingMode) {
            case self::ROUND_HALF_UP:
                return $this->roundHalfUp($number, $precision);
                break;
            case self::ROUND_CEIL:
                return $this->ceil($number, $precision);
                break;
            case self::ROUND_FLOOR:
                return $this->floor($number, $precision);
                break;
            case self::ROUND_HALF_DOWN:
                return $this->roundHalfDown($number, $precision);
                break;
            case self::ROUND_TRUNCATE:
                return $this->truncate($number, $precision);
                break;
            case self::ROUND_HALF_EVEN:
                return $this->roundHalfEven($number, $precision);
                break;
        }

        throw new \InvalidArgumentException(sprintf("Invalid rounding mode: %s", print_r($roundingMode, true)));
    }
1314843
public BigDecimal get(JcNumber number) {
		Object val = this.getFor(number);
		if (val != null)
			return (BigDecimal)val;
		return null;
	}
959131
public static BigDecimal rounddown(EvaluationContext ctx, Object number, Object numDigits) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        int _numDigits = Conversions.toInteger(numDigits, ctx);

        return ExpressionUtils.decimalRound(_number, _numDigits, RoundingMode.DOWN);
    }
1162859
public static String compactDecimal(final Number value)
    {
        NumberFormat fmt = context.get().getCompactDecimalFormat();
        return fmt.format(value);
    }
74185
public static Number toNumber(String string) {
    BigDecimal value = new BigDecimal(string);
    try {
      long l = value.longValueExact();
      int i = (int) l;
      if ((long) i == l) {
        return i;
      } else {
        return l;
      }
    } catch (ArithmeticException e) {
      double d = value.doubleValue();
      if (BigDecimal.valueOf(d).equals(value)) {
        float f = (float) d;
        if ((double) f == d) {
          return (float) d;
        } else {
          return d;
        }
      } else {
        return null;
      }
    }
  }
678838
public void truncateZeros( double tol ) {

//		double max = 0;
//		for( int i = 0; i < size; i++ ) {
//			double d = Math.abs(c[i]);
//			if( d > max )
//				max = d;
//		}
//
//		tol *= max;

		int i = size-1;

		for( ; i >= 0; i-- ) {
			if( Math.abs(c[i]) > tol )
				break;
		}
		size = i+1;
	}
804791
public static BigDecimal roundDown(BigDecimal value, int scale) {
		return round(value, scale, RoundingMode.DOWN);
	}
300622
public static String bitString(long number) {
        return String.format(Locale.ROOT,"%064d", new BigInteger(Long.toBinaryString(number)));
    }
448791
static BigDecimal decimal(String value) {
        BigDecimal result;
        if (value != null) {
            value = value.trim();
            Matcher matcher = DECIMAL_PATTERN.matcher(value);
            if (matcher.matches()) {
                result = new BigDecimal(matcher.group(1));
            } else {
                throw new IllegalArgumentException("Unknown format for value: " + value);
            }
        } else {
            result = null;
        }
        return result;
    }
1048544
public static float trunc(Float number) {
        if (number < 0f) {
            return (float)Math.ceil(number.doubleValue());
        }
        return (float)Math.floor(number.doubleValue());
    }
1209028
public double precision(int outputNum) {
        assertIndex(outputNum);
        //double precision = tp / (double) (tp + fp);
        return countTruePositive[outputNum] / (double) (countTruePositive[outputNum] + countFalsePositive[outputNum]);
    }
664460
public static Decimal fromUnscaledBytes(int precision, int scale, byte[] bytes) {
		if (precision > MAX_COMPACT_PRECISION) {
			BigDecimal bd = new BigDecimal(new BigInteger(bytes), scale);
			return new Decimal(precision, scale, -1, bd);
		}
		assert bytes.length == 8;
		long l = 0;
		for (int i = 0; i < 8; i++) {
			l <<= 8;
			l |= (bytes[i] & (0xff));
		}
		return new Decimal(precision, scale, l, null);
	}
642889
public static BigDecimal decimalPow(BigDecimal number, BigDecimal power) {
        return new BigDecimal(Math.pow(number.doubleValue(), power.doubleValue()), MATH);
    }
701924
def truncate(value: Decimal, n_digits: int) -> Decimal:
    """"""
    return Decimal(math.trunc(value * (10 ** n_digits))) / (10 ** n_digits)
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)))));
    }