code: public static BigDecimal getBigDecimal(double num) {
          if (Double.isNaN(num)) {
              throw new ArithmeticException("Invalid input Double.NaN.");
          } else if(Double.isInfinite(num)) {
              throw new ArithmeticException("Invalid input Double.xxx_INFINITY.");
          }
          return new BigDecimal(String.valueOf(num));
      }
docs: Creates a {@link BigDecimal} from the given {@link Number} doing the
  valid conversion depending the type given.
  
  @param num the number type
  @return the corresponding {@link BigDecimal}