/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
public static void serialize(SerializationStreamWriter streamWriter, MathContext instance) throws SerializationException { streamWriter.writeInt(instance.getPrecision()); streamWriter.writeInt(instance.getRoundingMode().ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Returns the hash code for this {@code MathContext} instance. * * @return the hash code for this {@code MathContext}. */ @Override public int hashCode() { // Make place for the necessary bits to represent 8 rounding modes return ((precision << 3) | roundingMode.ordinal()); }
/** * Method to get BigDecimal rounding mode from a property. Use the default arithmeticPropertiesFile properties file * @param property - Name of the config property from arithmeticPropertiesFile (e.g., "invoice.rounding") * @return int - Rounding mode to pass to BigDecimal's methods. Defaults to BigDecimal.ROUND_HALF_UP * @deprecated Use {@link #getRoundingMode(String)} instead */ @Deprecated public static int getBigDecimalRoundingMode(String property) { return getRoundingMode(arithmeticPropertiesFile, property).ordinal(); }
/** * Method to get BigDecimal rounding mode from a property * @param file - Name of the property file * @param property - Name of the config property from arithmeticPropertiesFile (e.g., "invoice.rounding") * @return int - Rounding mode to pass to BigDecimal's methods. Defaults to BigDecimal.ROUND_HALF_UP * @deprecated Use {@link #getRoundingMode(String,String)} instead */ @Deprecated public static int getBigDecimalRoundingMode(String file, String property) { return getRoundingMode(file, property).ordinal(); }
/** * Calculate new returnAdjustment amount and set scale and rounding mode based on returnAdjustmentType: RET_SALES_TAX_ADJ use sales.tax._ and others use order._ * @param isSalesTax if returnAdjustmentType is SaleTax * @param returnTotal * @param originalTotal * @param amount * @return new returnAdjustment amount */ public static BigDecimal getAdjustmentAmount(boolean isSalesTax, BigDecimal returnTotal, BigDecimal originalTotal, BigDecimal amount) { String settingPrefix = isSalesTax ? "salestax" : "order"; String decimalsPrefix = isSalesTax ? ".calc" : ""; int decimals = UtilNumber.getBigDecimalScale(settingPrefix + decimalsPrefix + ".decimals"); int rounding = UtilNumber.getRoundingMode(settingPrefix + ".rounding").ordinal(); returnTotal = returnTotal.setScale(decimals, rounding); originalTotal = originalTotal.setScale(decimals, rounding); BigDecimal newAmount = null; if (ZERO.compareTo(originalTotal) != 0) { newAmount = returnTotal.multiply(amount).divide(originalTotal, decimals, rounding); } else { newAmount = ZERO; } return newAmount; } }
/** * {@icu} Sets the MathContext used by this format. * * @param newValue desired MathContext * @see #getMathContext * @stable ICU 4.2 */ public void setMathContext(java.math.MathContext newValue) { mathContext = new MathContext(newValue.getPrecision(), MathContext.SCIENTIFIC, false, (newValue.getRoundingMode()).ordinal()); }
public static void serialize(SerializationStreamWriter streamWriter, MathContext instance) throws SerializationException { streamWriter.writeInt(instance.getPrecision()); streamWriter.writeInt(instance.getRoundingMode().ordinal()); }
public static void serialize(SerializationStreamWriter streamWriter, MathContext instance) throws SerializationException { streamWriter.writeInt(instance.getPrecision()); streamWriter.writeInt(instance.getRoundingMode().ordinal()); }
RubyFixnum roundingMode = runtime.newFixnum(javaRoundingMode.ordinal()); c.setInternalModuleVariable("vpRoundingMode", roundingMode);
RubyFixnum roundingMode = runtime.newFixnum(javaRoundingMode.ordinal()); c.setInternalModuleVariable("vpRoundingMode", roundingMode);