/** * Returns the value by which the{@link #getEstimatedValue() estimated * value} may differ from the true value (all stated in base units). * * @return the absolute error stated in base units. */ public double getAbsoluteError() { return MathLib.abs(_maximum - _minimum) * 0.5; }
/** * Formats the specified <code>float</code> value. * * @param f the <code>float</code> value. * @param a the <code>Appendable</code> to append. * @return <code>TypeFormat.format(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false, a)</code> * @throws IOException if an I/O exception occurs. */ public static Appendable format(float f, Appendable a) throws IOException { return TypeFormat.format(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false, a); }
/** * Formats the specified <code>double</code> value (16 or 17 digits output). * * @param d the <code>double</code> value. * @param a the <code>Appendable</code> to append. * @return <code>TypeFormat.format(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false, a)</code> * @throws IOException if an I/O exception occurs. * @see TextBuilder#append(double) */ public static Appendable format(double d, Appendable a) throws IOException { return TypeFormat.format(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false, a); }
/** * Appends the textual representation of the specified <code>float</code>. * * @param f the <code>float</code> to format. * @return <code>append(f, 10, (abs(f) >= 1E7) || (abs(f) < 0.001), false)</code> */ public final TextBuilder append(float f) { return append(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false); }
/** * Formats the specified <code>float</code> value. * * @param f the <code>float</code> value. * @param a the <code>Appendable</code> to append. * @return <code>TypeFormat.format(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false, a)</code> * @throws IOException if an I/O exception occurs. */ public static Appendable format(float f, Appendable a) throws IOException { return TypeFormat.format(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false, a); }
/** * Appends the textual representation of the specified <code>float</code>. * * @param f the <code>float</code> to format. * @return <code>append(f, 10, (abs(f) >= 1E7) || (abs(f) < 0.001), false)</code> */ public final TextBuilder append(float f) { return append(f, 10, (MathLib.abs(f) >= 1E7) || (MathLib.abs(f) < 0.001), false); }
/** * Appends the textual representation of the specified <code>double</code>; * the number of digits is 17 or 16 when the 16 digits representation * can be parsed back to the same <code>double</code> (mimic the standard * library formatting). * * @param d the <code>double</code> to format. * @return <code>append(d, -1, (MathLib.abs(d) >= 1E7) || * (MathLib.abs(d) < 0.001), false)</code> */ public final TextBuilder append(double d) { return append(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false); }
/** * Formats the specified <code>double</code> value (16 or 17 digits output). * * @param d the <code>double</code> value. * @param a the <code>Appendable</code> to append. * @return <code>TypeFormat.format(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false, a)</code> * @throws IOException if an I/O exception occurs. * @see TextBuilder#append(double) */ public static Appendable format(double d, Appendable a) throws IOException { return TypeFormat.format(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false, a); }
/** * Appends the textual representation of the specified <code>double</code>; * the number of digits is 17 or 16 when the 16 digits representation * can be parsed back to the same <code>double</code> (mimic the standard * library formatting). * * @param d the <code>double</code> to format. * @return <code>append(d, -1, (MathLib.abs(d) >= 1E7) || * (MathLib.abs(d) < 0.001), false)</code> */ public final TextBuilder append(double d) { return append(d, -1, (MathLib.abs(d) >= 1E7) || (MathLib.abs(d) < 0.001), false); }
/** * Returns the absolute value of this number. * * @return <code>|this|</code>. */ public Float64 abs() { Float64 r = FACTORY.object(); r._value = MathLib.abs(this._value); return r; }
/** * Returns the absolute value of this number. * * @return <code>|this|</code>. */ public Integer64 abs() { Integer64 r = FACTORY.object(); r._value = MathLib.abs(this._value); return r; }
/** * 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; }
/** * Indicates if two complexes are "sufficiently" alike to be considered * equal. * * @param that the complex to compare with. * @param tolerance the maximum magnitude of the difference between * them before they are considered <i>not</i> equal. * @return <code>true</code> if they are considered equal; * <code>false</code> otherwise. */ public boolean equals(Complex that, double tolerance) { return MathLib.abs(this.minus(that).magnitude()) <= tolerance; }
/** * Returns the product of this large integer with the specified * <code>long</code> multiplier. * * @param multiplier the <code>long</code> multiplier. * @return <code>this · multiplier</code>. */ public LargeInteger times(long multiplier) { if ((this._size == 0) || (multiplier == 0)) return LargeInteger.ZERO; if (multiplier == Long.MIN_VALUE) return times(LONG_MIN_VALUE); // Size 2. boolean isNegative = _isNegative ^ (multiplier < 0); multiplier = MathLib.abs(multiplier); LargeInteger li = ARRAY_FACTORY.array(_size + 1); li._size = Calculus.multiply(_words, _size, multiplier, li._words); li._isNegative = isNegative; return li; }
/** * Returns the real number (inexact except for <code>0.0</code>) * corresponding to the specified <code>double</code> value. * The error is derived from the inexact representation of * <code>double</code> values intrinsic to the 64 bits IEEE 754 format. * * @param doubleValue the <code>double</code> value to convert. * @return the corresponding real number. */ public static Real valueOf(double doubleValue) { if (doubleValue == 0.0) return Real.ZERO; if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) return Real.NaN; // Find the exponent e such as: value == x.xxx * 10^e int e = MathLib.floorLog10(MathLib.abs(doubleValue)) - 18 + 1; // 18 digits significand. long significand = MathLib.toLongPow10(doubleValue, -e); int error = (int) MathLib.toLongPow10(Math.ulp(doubleValue), -e) + 1; return Real.valueOf(LargeInteger.valueOf(significand), error, e); }