code: public static BigDecimal toDecimal(Object value, EvaluationContext ctx) {
          if (value instanceof Boolean) {
              return ((Boolean) value) ? BigDecimal.ONE : BigDecimal.ZERO;
          }
          else if (value instanceof Integer) {
              return new BigDecimal((Integer) value);
          }
          else if (value instanceof BigDecimal) {
              return (BigDecimal) value;
          }
          else if (value instanceof String) {
              try {
                  return new BigDecimal((String) value);
              }
              catch (NumberFormatException e) {}
          }
  
          throw new EvaluationError("Can't convert '" + value + "' to a decimal");
      }
docs: Tries conversion of any value to a decimal