/** * Returns the closest integer value to this 64 bits floating point number. * * @return this number rounded to the nearest integer. */ public long round() { return MathLib.round(_value); }
/** * Returns the remainder of the division of the specified two arguments. * * @param x the dividend. * @param y the divisor. * @return <code>x - round(x / y) * y</code> **/ public static double rem(double x, double y) { double tmp = x / y; if (MathLib.abs(tmp) <= Long.MAX_VALUE) return x - MathLib.round(tmp) * y; else return NaN; } /**/
/** * Returns the remainder of the division of the specified two arguments. * * @param x the dividend. * @param y the divisor. * @return <code>x - round(x / y) * y</code> **/ public static double rem(double x, double y) { double tmp = x / y; if (MathLib.abs(tmp) <= Long.MAX_VALUE) return x - MathLib.round(tmp) * y; else return NaN; }
/** * Returns the remainder of the division of the specified two arguments. * * @param x the dividend. * @param y the divisor. * @return <code>x - round(x / y) * y</code> **/ public static double rem(double x, double y) { double tmp = x / y; if (MathLib.abs(tmp) <= Long.MAX_VALUE) return x - MathLib.round(tmp) * y; else return NaN; }
/** * Returns the remainder of the division of the specified two arguments. * * @param x the dividend. * @param y the divisor. * @return <code>x - round(x / y) * y</code> **/ public static double rem(double x, double y) { double tmp = x / y; if (MathLib.abs(tmp) <= Long.MAX_VALUE) return x - MathLib.round(tmp) * y; else return NaN; }
/** * Provides custom formatting for money measurements. */ private static Appendable formatMoney(Amount<Money> arg0, Appendable arg1) throws IOException { Currency currency = (Currency) arg0.getUnit(); int fraction = currency.getDefaultFractionDigits(); if (fraction == 0) { long amount = arg0.longValue(currency); TypeFormat.format(amount, arg1); } else if (fraction == 2) { long amount = MathLib.round(arg0.doubleValue(arg0.getUnit()) * 100); TypeFormat.format(amount / 100, arg1); arg1.append('.'); arg1.append((char) ('0' + (amount % 100) / 10)); arg1.append((char) ('0' + (amount % 10))); } else { throw new UnsupportedOperationException(); } arg1.append(' '); return UnitFormat.getInstance().format(currency, arg1); }