/** * Returns the largest power of 10 that is less than or equal to the * the specified positive value. * * @param d the <code>double</code> number. * @return <code>floor(Log10(abs(d)))</code> * @throws ArithmeticException if <code>d <= 0<code> or <code>d</code> * is <code>NaN</code> or <code>Infinity</code>. **/ public static int floorLog10(double d) { int guess = (int) (LOG2_DIV_LOG10 * MathLib.floorLog2(d)); double pow10 = MathLib.toDoublePow10(1, guess); if ((pow10 <= d) && (pow10 * 10 > d)) return guess; if (pow10 > d) return guess - 1; return guess + 1; }
/** * Returns the largest power of 10 that is less than or equal to the * the specified positive value. * * @param d the <code>double</code> number. * @return <code>floor(Log10(abs(d)))</code> * @throws ArithmeticException if <code>d <= 0<code> or <code>d</code> * is <code>NaN</code> or <code>Infinity</code>. **/ public static int floorLog10(double d) { int guess = (int) (LOG2_DIV_LOG10 * MathLib.floorLog2(d)); double pow10 = MathLib.toDoublePow10(1, guess); if ((pow10 <= d) && (pow10 * 10 > d)) return guess; if (pow10 > d) return guess - 1; return guess + 1; }
/** * Returns the largest power of 10 that is less than or equal to the * the specified positive value. * * @param d the <code>double</code> number. * @return <code>floor(Log10(abs(d)))</code> * @throws ArithmeticException if <code>d <= 0<code> or <code>d</code> * is <code>NaN</code> or <code>Infinity</code>. **/ public static int floorLog10(double d) { int guess = (int) (LOG2_DIV_LOG10 * MathLib.floorLog2(d)); double pow10 = MathLib.toDoublePow10(1, guess); if ((pow10 <= d) && (pow10 * 10 > d)) return guess; if (pow10 > d) return guess - 1; return guess + 1; } private static final double LOG2_DIV_LOG10 = 0.3010299956639811952137388947;
/** * Returns the largest power of 10 that is less than or equal to the * the specified positive value. * * @param d the <code>double</code> number. * @return <code>floor(Log10(abs(d)))</code> * @throws ArithmeticException if <code>d <= 0<code> or <code>d</code> * is <code>NaN</code> or <code>Infinity</code>. **/ public static int floorLog10(double d) { int guess = (int) (LOG2_DIV_LOG10 * MathLib.floorLog2(d)); double pow10 = MathLib.toDoublePow10(1, guess); if ((pow10 <= d) && (pow10 * 10 > d)) return guess; if (pow10 > d) return guess - 1; return guess + 1; }
/** * Returns the value of this real number as a <code>double</code>. * * @return the numeric value represented by this real after conversion * to type <code>double</code>. */ public double doubleValue() { if (this == NaN) return Double.NaN; if (this == ZERO) return 0.0; // Shift the significand to a >18 digits integer (long compatible). int nbrDigits = _significand.digitLength(); int digitShift = nbrDigits - 18; long reducedSignificand = _significand.times10pow(-digitShift).longValue(); int exponent = _exponent + digitShift; return MathLib.toDoublePow10(reducedSignificand, exponent); }
return javolution.lang.MathLib.toDoublePow10(decimal, exp - fractionLength);
return javolution.lang.MathLib.toDoublePow10(decimal, exp - fractionLength);
return 0.0; if (m == Long.MIN_VALUE) return toDoublePow10(Long.MIN_VALUE / 10, n + 1); if (m < 0) return -toDoublePow10(-m, n); if (n >= 0) { // Positive power. if (n > 308)
return 0.0; if (m == Long.MIN_VALUE) return toDoublePow10(Long.MIN_VALUE / 10, n + 1); if (m < 0) return -toDoublePow10(-m, n); if (n >= 0) { // Positive power. if (n > 308)
return 0.0; if (m == Long.MIN_VALUE) return toDoublePow10(Long.MIN_VALUE / 10, n + 1); if (m < 0) return -toDoublePow10(-m, n); if (n >= 0) { // Positive power. if (n > 308)
return 0.0; if (m == Long.MIN_VALUE) return toDoublePow10(Long.MIN_VALUE / 10, n + 1); if (m < 0) return -toDoublePow10(-m, n); if (n >= 0) { // Positive power. if (n > 308)
break; int bracketError = (int) (error * MathLib.toDoublePow10(1, -log10Error + _errorDigits - 1)); tb.insert(endMantissa, Text.valueOf('[').plus(
double dd = MathLib.toDoublePow10(m16, e - 16 + 1); if (dd == d) { // 16 digits is enough. digits = 16;
double dd = MathLib.toDoublePow10(m16, e - 16 + 1); if (dd == d) { // 16 digits is enough. digits = 16;