Returns this rational number as a {@link BigDecimal}.

@return the {@link BigDecimal} value
425368
public BigDecimal toBigDecimal() {
		int precision = Math.max(precision(), MathContext.DECIMAL128.getPrecision());
		return toBigDecimal(new MathContext(precision));
	}
517854
public final BigDecimal getDecimalAsBigDecimal(int columnIndex) {
        validateColumnType(columnIndex, VoltType.DECIMAL);
        final int position = m_buffer.position();
        m_buffer.position(getOffset(columnIndex));
        final BigDecimal bd = VoltDecimalHelper.deserializeBigDecimal(m_buffer);
        m_buffer.position(position);
        m_wasNull = bd == null ? true : false;
        return bd;
    }
944123
public static BigDecimal randomBigDecimal(BigDecimal limit) {
		return NumberUtil.toBigDecimal(getRandom().nextDouble(limit.doubleValue()));
	}
1233037
public static BigDecimal toBigDecimal(Number self) {
        // Quick method for scalars.
        if ((self instanceof Long)
                || (self instanceof Integer)
                || (self instanceof Short)
                || (self instanceof Byte))
        {
            return BigDecimal.valueOf(self.longValue());
        }

        return new BigDecimal(self.toString());
    }
991025
public static BigDecimal inverse(final BigDecimal value) {
        if (isNotZero(value)) {
            return BigDecimal.ONE.setScale(MAX_SCALE_FOR_INVERSE).divide(value, BigDecimal.ROUND_HALF_UP);
        }
        return null;
    }
430030
public BigDecimal remainder() {
	    BigDecimal out = toBigDecimal();
		BigDecimal fraction = out.remainder(BigDecimal.ONE);
		return fraction;
	}
971502
public BigDecimal toBigDecimal(Integer scale, Rounding rounding, boolean stripTrailingZeros) {
	    out = this.in;
	    
	    if (scale != null && rounding != null)
	        out = out.setScale(scale, rounding.getBigDecimalRound());
	    else if (scale != null && rounding == null)
	        out = out.setScale(scale);
	    
	    if (stripTrailingZeros)
	        out = out.stripTrailingZeros();
	    
	    return out;
	}
288356
private BigDecimal toBigDecimal(Object value) {
		if (value instanceof Long) {
			return new BigDecimal((Long) value);
		} else if (value instanceof Integer) {
			return new BigDecimal((Integer) value);
		} else if (value instanceof BigInteger) {
			return new BigDecimal((BigInteger) value);
		} else if(value instanceof Boolean) {
			return new BigDecimal((boolean)value ? 1 : 0);
		}

		//对于Double类型，先要转换为String，避免精度问题
		final String valueStr = convertToStr(value);
		if (StrUtil.isBlank(valueStr)) {
			return null;
		}
		return new BigDecimal(valueStr);
	}
636805
protected BigDecimal coerceToBigDecimal(Value value) {
		
		if (!(value instanceof NumberValue))
			throw new CommandExecutionException("Value is not a number");
		return ((NumberValue) value).get();
	}
222838
public BigDecimal getBigDecimal(String key) throws JSONException {
		Object object = this.get(key);
		try {
			return new BigDecimal(object.toString());
		} catch (Exception e) {
			throw new JSONException("JSONObject[" + quote(key)
					+ "] could not be converted to BigDecimal.");
		}
	}
500723
public Decimal floor() {
		BigDecimal bd = toBigDecimal().setScale(0, RoundingMode.FLOOR);
		return fromBigDecimal(bd, bd.precision(), 0);
	}
1304687
public BigDecimal getInternalBigDecimal(ColumnInformation columnInfo) {
    if (lastValueWasNull()) {
      return null;
    }

    if (columnInfo.getColumnType() == ColumnType.BIT) {
      return BigDecimal.valueOf(parseBit());
    }
    return new BigDecimal(new String(buf, pos, length, StandardCharsets.UTF_8));
  }
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;
    }
1142740
public BigDecimal getBigDecimal( int index ) throws OdaException
	{
		BigDecimal value = (BigDecimal) getFieldValue(index);
		return  value==null?new BigDecimal(0):value;
	}
982994
public float floatValue() {
        BigDecimal adivb = (new BigDecimal(a)).divide(new BigDecimal(b), MathContext.DECIMAL128);
        return adivb.floatValue();
    }
1304297
public BigInteger toBigInteger() {
        byte[] magnitude = new byte[nWords * 4 + 1];
        for (int i = 0; i < nWords; i++) {
            int w = data[i];
            magnitude[magnitude.length - 4 * i - 1] = (byte) w;
            magnitude[magnitude.length - 4 * i - 2] = (byte) (w >> 8);
            magnitude[magnitude.length - 4 * i - 3] = (byte) (w >> 16);
            magnitude[magnitude.length - 4 * i - 4] = (byte) (w >> 24);
        }
        return new BigInteger(magnitude).shiftLeft(offset * 32);
    }
248593
public static BigInteger toBigInteger(Number self) {
        if (self instanceof BigInteger) {
            return (BigInteger) self;
        } else if (self instanceof BigDecimal) {
            return ((BigDecimal) self).toBigInteger();
        } else if (self instanceof Double) {
            return new BigDecimal((Double)self).toBigInteger();
        } else if (self instanceof Float) {
            return new BigDecimal((Float)self).toBigInteger();
        } else {
            return new BigInteger(Long.toString(self.longValue()));
        }
    }