/** * Returns the closest <code>int</code> to the specified argument. * * @param f the <code>float</code> value to be rounded to a <code>int</code> * @return the nearest <code>int</code> value. **/ public static int round(float f) { return (int) floor(f + 0.5f); } /**/
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); }
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); } /**/
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); }
/** * Returns the closest <code>int</code> to the specified argument. * * @param f the <code>float</code> value to be rounded to a <code>int</code> * @return the nearest <code>int</code> value. **/ public static int round(float f) { return (int) floor(f + 0.5f); }
/** * Returns the closest <code>int</code> to the specified argument. * * @param f the <code>float</code> value to be rounded to a <code>int</code> * @return the nearest <code>int</code> value. **/ public static int round(float f) { return (int) floor(f + 0.5f); }
/** * Returns the closest <code>long</code> to the specified argument. * * @param d the <code>double</code> value to be rounded to a * <code>long</code> * @return the nearest <code>long</code> value. **/ public static long round(double d) { return (long) floor(d + 0.5d); }
/** * Returns the closest <code>int</code> to the specified argument. * * @param f the <code>float</code> value to be rounded to a <code>int</code> * @return the nearest <code>int</code> value. **/ public static int round(float f) { return (int) floor(f + 0.5f); }
@SuppressWarnings("unchecked") @Override public Appendable format(Amount arg0, Appendable arg1) throws IOException { if (arg0.getUnit() instanceof Currency) return formatMoney(arg0, arg1); if (arg0.isExact()) { TypeFormat.format(arg0.getExactValue(), arg1); arg1.append(' '); return UnitFormat.getInstance().format(arg0.getUnit(), arg1); } double value = arg0.getEstimatedValue(); double error = arg0.getAbsoluteError(); int log10Value = (int) MathLib.floor(MathLib.log10(MathLib .abs(value))); int log10Error = (int) MathLib.floor(MathLib.log10(error)); int digits = log10Value - log10Error - 1; // Exact digits. boolean scientific = (MathLib.abs(value) >= 1E6) || (MathLib.abs(value) < 1E-6); boolean showZeros = true; TypeFormat.format(value, digits, scientific, showZeros, arg1); arg1.append(' '); return UnitFormat.getInstance().format(arg0.getUnit(), arg1); }