Codota Logo
MathLib.floorLog2
Code IndexAdd Codota to your IDE (free)

How to use
floorLog2
method
in
javolution.lang.MathLib

Best Java code snippets using javolution.lang.MathLib.floorLog2 (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: org.apache.marmotta/marmotta-commons

/**
 * Returns the largest power of 2 that is less than or equal to the
 * the specified positive value.
 *
 * @param d the <code>double</code> number.
 * @return <code>floor(Log2(abs(d)))</code>
 * @throws ArithmeticException if <code>d &lt;= 0<code> or <code>d</code>
 *         is <code>NaN</code> or <code>Infinity</code>.
 **/
public static int floorLog2(double d) {
  if (d <= 0)
    throw new ArithmeticException("Negative number or zero");
  long bits = Double.doubleToLongBits(d);
  int exp = ((int) (bits >> 52)) & 0x7FF;
  if (exp == 0x7FF)
    throw new ArithmeticException("Infinity or NaN");
  if (exp == 0)
    return floorLog2(d * 18014398509481984L) - 54; // 2^54 Exact.       
  return exp - 1023;
}
origin: apache/marmotta

/**
 * Returns the largest power of 2 that is less than or equal to the
 * the specified positive value.
 *
 * @param d the <code>double</code> number.
 * @return <code>floor(Log2(abs(d)))</code>
 * @throws ArithmeticException if <code>d &lt;= 0<code> or <code>d</code>
 *         is <code>NaN</code> or <code>Infinity</code>.
 **/
public static int floorLog2(double d) {
  if (d <= 0)
    throw new ArithmeticException("Negative number or zero");
  long bits = Double.doubleToLongBits(d);
  int exp = ((int) (bits >> 52)) & 0x7FF;
  if (exp == 0x7FF)
    throw new ArithmeticException("Infinity or NaN");
  if (exp == 0)
    return floorLog2(d * 18014398509481984L) - 54; // 2^54 Exact.       
  return exp - 1023;
}
origin: javolution/javolution

/**
 * Returns the largest power of 2 that is less than or equal to the
 * the specified positive value.
 *
 * @param d the <code>double</code> number.
 * @return <code>floor(Log2(abs(d)))</code>
 * @throws ArithmeticException if <code>d &lt;= 0<code> or <code>d</code>
 *         is <code>NaN</code> or <code>Infinity</code>.
 **/
public static int floorLog2(double d) {
  if (d <= 0)
    throw new ArithmeticException("Negative number or zero");
  long bits = Double.doubleToLongBits(d);
  int exp = ((int) (bits >> 52)) & 0x7FF;
  if (exp == 0x7FF)
    throw new ArithmeticException("Infinity or NaN");
  if (exp == 0)
    return floorLog2(d * 18014398509481984L) - 54;  // 2^54 Exact.       
  return exp - 1023;
}
/**/
origin: org.javolution/javolution-core-java

/**
 * Returns the largest power of 2 that is less than or equal to the
 * the specified positive value.
 *
 * @param d the <code>double</code> number.
 * @return <code>floor(Log2(abs(d)))</code>
 * @throws ArithmeticException if <code>d &lt;= 0<code> or <code>d</code>
 *         is <code>NaN</code> or <code>Infinity</code>.
 **/
public static int floorLog2(double d) {
  if (d <= 0)
    throw new ArithmeticException("Negative number or zero");
  long bits = Double.doubleToLongBits(d);
  int exp = ((int) (bits >> 52)) & 0x7FF;
  if (exp == 0x7FF)
    throw new ArithmeticException("Infinity or NaN");
  if (exp == 0)
    return floorLog2(d * 18014398509481984L) - 54; // 2^54 Exact.       
  return exp - 1023;
}
origin: apache/marmotta

/**
 * 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 &lt;= 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;
}
origin: org.apache.marmotta/marmotta-commons

/**
 * 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 &lt;= 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;
}
origin: javolution/javolution

/**
 * 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 &lt;= 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;
origin: org.javolution/javolution-core-java

/**
 * 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 &lt;= 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;
}
javolution.langMathLibfloorLog2

Javadoc

Returns the largest power of 2 that is less than or equal to the the specified positive value.

Popular methods of MathLib

  • min
    Returns the smaller of two long values.
  • sqrt
    Returns the positive square root of the specified value.
  • abs
    Returns the absolute value of the specified long argument.
  • bitLength
    Returns the number of bits in the minimal two's-complement representation of the specified long, exc
  • exp
    Returns #E raised to the specified power.
  • floor
    Returns the largest (closest to positive infinity)double value that is not greater than the argument
  • log
    Returns the natural logarithm (base #E) of the specified value.
  • max
    Returns the greater of two long values.
  • pow
    Returns the value of the first argument raised to the power of the second argument.
  • round
    Returns the closest int to the specified argument.
  • toDoublePow10
    Returns the closest double representation of the specified long number multiplied by a power of ten.
  • toDoublePow2
    Returns the closest double representation of the specified long number multiplied by a power of two.
  • toDoublePow10,
  • toDoublePow2,
  • toLongPow10,
  • _atan,
  • _ieee754_exp,
  • _ieee754_log,
  • asin,
  • atan,
  • digitLength,
  • floorLog10

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now