Tabnine Logo
Long.numberOfTrailingZeros
Code IndexAdd Tabnine to your IDE (free)

How to use
numberOfTrailingZeros
method
in
java.lang.Long

Best Java code snippets using java.lang.Long.numberOfTrailingZeros (Showing top 20 results out of 2,088)

origin: libgdx/libgdx

protected Attribute (final long type) {
  this.type = type;
  this.typeBit = Long.numberOfTrailingZeros(type);
}
origin: libgdx/libgdx

protected Attribute (final long type) {
  this.type = type;
  this.typeBit = Long.numberOfTrailingZeros(type);
}
origin: pxb1988/dex2jar

public static int lengthOfDouble(double value) {
  int requiredBits = 64 - Long.numberOfTrailingZeros(Double.doubleToRawLongBits(value));
  if (requiredBits == 0) {
    requiredBits = 1;
  }
  return (requiredBits + 0x07) >> 3;
}
origin: pxb1988/dex2jar

public static int lengthOfFloat(float value) {
  int requiredBits = 64 - Long.numberOfTrailingZeros(((long) (Float.floatToRawIntBits(value))) << 32);
  if (requiredBits == 0) {
    requiredBits = 1;
  }
  return (requiredBits + 0x07) >> 3;
}
origin: libgdx/libgdx

/** Creates a new map with the specified initial capacity and load factor. This map will hold initialCapacity items before
 * growing the backing table.
 * @param initialCapacity If not a power of two, it is increased to the next nearest power of two. */
public LongMap (int initialCapacity, float loadFactor) {
  if (initialCapacity < 0) throw new IllegalArgumentException("initialCapacity must be >= 0: " + initialCapacity);
  initialCapacity = MathUtils.nextPowerOfTwo((int)Math.ceil(initialCapacity / loadFactor));
  if (initialCapacity > 1 << 30) throw new IllegalArgumentException("initialCapacity is too large: " + initialCapacity);
  capacity = initialCapacity;
  if (loadFactor <= 0) throw new IllegalArgumentException("loadFactor must be > 0: " + loadFactor);
  this.loadFactor = loadFactor;
  threshold = (int)(capacity * loadFactor);
  mask = capacity - 1;
  hashShift = 63 - Long.numberOfTrailingZeros(capacity);
  stashCapacity = Math.max(3, (int)Math.ceil(Math.log(capacity)) * 2);
  pushIterations = Math.max(Math.min(capacity, 8), (int)Math.sqrt(capacity) / 8);
  keyTable = new long[capacity + stashCapacity];
  valueTable = (V[])new Object[keyTable.length];
}
origin: libgdx/libgdx

/** Creates a new map with the specified initial capacity and load factor. This map will hold initialCapacity items before
 * growing the backing table.
 * @param initialCapacity If not a power of two, it is increased to the next nearest power of two. */
public LongMap (int initialCapacity, float loadFactor) {
  if (initialCapacity < 0) throw new IllegalArgumentException("initialCapacity must be >= 0: " + initialCapacity);
  initialCapacity = MathUtils.nextPowerOfTwo((int)Math.ceil(initialCapacity / loadFactor));
  if (initialCapacity > 1 << 30) throw new IllegalArgumentException("initialCapacity is too large: " + initialCapacity);
  capacity = initialCapacity;
  if (loadFactor <= 0) throw new IllegalArgumentException("loadFactor must be > 0: " + loadFactor);
  this.loadFactor = loadFactor;
  threshold = (int)(capacity * loadFactor);
  mask = capacity - 1;
  hashShift = 63 - Long.numberOfTrailingZeros(capacity);
  stashCapacity = Math.max(3, (int)Math.ceil(Math.log(capacity)) * 2);
  pushIterations = Math.max(Math.min(capacity, 8), (int)Math.sqrt(capacity) / 8);
  keyTable = new long[capacity + stashCapacity];
  valueTable = (V[])new Object[keyTable.length];
}
origin: libgdx/libgdx

private void resize (int newSize) {
  int oldEndIndex = capacity + stashSize;
  capacity = newSize;
  threshold = (int)(newSize * loadFactor);
  mask = newSize - 1;
  hashShift = 63 - Long.numberOfTrailingZeros(newSize);
  stashCapacity = Math.max(3, (int)Math.ceil(Math.log(newSize)) * 2);
  pushIterations = Math.max(Math.min(newSize, 8), (int)Math.sqrt(newSize) / 8);
  long[] oldKeyTable = keyTable;
  V[] oldValueTable = valueTable;
  keyTable = new long[newSize + stashCapacity];
  valueTable = (V[])new Object[newSize + stashCapacity];
  int oldSize = size;
  size = hasZeroValue ? 1 : 0;
  stashSize = 0;
  if (oldSize > 0) {
    for (int i = 0; i < oldEndIndex; i++) {
      long key = oldKeyTable[i];
      if (key != EMPTY) putResize(key, oldValueTable[i]);
    }
  }
}
origin: libgdx/libgdx

private void resize (int newSize) {
  int oldEndIndex = capacity + stashSize;
  capacity = newSize;
  threshold = (int)(newSize * loadFactor);
  mask = newSize - 1;
  hashShift = 63 - Long.numberOfTrailingZeros(newSize);
  stashCapacity = Math.max(3, (int)Math.ceil(Math.log(newSize)) * 2);
  pushIterations = Math.max(Math.min(newSize, 8), (int)Math.sqrt(newSize) / 8);
  long[] oldKeyTable = keyTable;
  V[] oldValueTable = valueTable;
  keyTable = new long[newSize + stashCapacity];
  valueTable = (V[])new Object[newSize + stashCapacity];
  int oldSize = size;
  size = hasZeroValue ? 1 : 0;
  stashSize = 0;
  if (oldSize > 0) {
    for (int i = 0; i < oldEndIndex; i++) {
      long key = oldKeyTable[i];
      if (key != EMPTY) putResize(key, oldValueTable[i]);
    }
  }
}
origin: vavr-io/vavr

@Override
public T head() {
  if (elements == 0) {
    throw new NoSuchElementException("head of empty BitSet");
  } else {
    return fromInt.apply(Long.numberOfTrailingZeros(elements));
  }
}
origin: vavr-io/vavr

@Override
public T head() {
  if (elements1 == 0) {
    return fromInt.apply(BITS_PER_WORD + Long.numberOfTrailingZeros(elements2));
  } else {
    return fromInt.apply(Long.numberOfTrailingZeros(elements1));
  }
}
origin: vavr-io/vavr

@Override
protected T getNext() {
  final int pos = Long.numberOfTrailingZeros(element);
  element &= ~(1L << pos);
  return bitSet.fromInt.apply(pos + (index << ADDRESS_BITS_PER_WORD));
}
origin: google/guava

int n = Long.numberOfTrailingZeros(lw ^ rw) & ~0x7;
return ((int) ((lw >>> n) & UNSIGNED_MASK)) - ((int) ((rw >>> n) & UNSIGNED_MASK));
origin: google/guava

 /** Returns true if n is a strong probable prime relative to the specified base. */
 private boolean testWitness(long base, long n) {
  int r = Long.numberOfTrailingZeros(n - 1);
  long d = (n - 1) >> r;
  base %= n;
  if (base == 0) {
   return true;
  }
  // Calculate a := base^d mod n.
  long a = powMod(base, d, n);
  // n passes this test if
  //    base^d = 1 (mod n)
  // or base^(2^j * d) = -1 (mod n) for some 0 <= j < r.
  if (a == 1) {
   return true;
  }
  int j = 0;
  while (a != n - 1) {
   if (++j == r) {
    return false;
   }
   a = squareMod(a, n);
  }
  return true;
 }
}
origin: neo4j/neo4j

public static void readBitmap( long bitmap, long labelId, MutableLongList[] labelsPerNode )
{
  while ( bitmap != 0 )
  {
    int relativeNodeId = Long.numberOfTrailingZeros( bitmap );
    if ( labelsPerNode[relativeNodeId] == null )
    {
      labelsPerNode[relativeNodeId] = new LongArrayList();
    }
    labelsPerNode[relativeNodeId].add( labelId );
    bitmap &= bitmap - 1;
  }
}
origin: Tencent/tinker

/**
 * Writes a right-zero-extended value to {@code out}.
 */
public static void writeRightZeroExtendedValue(ByteOutput out, int type, long value) {
  // Figure out how many bits are needed to represent the value.
  int requiredBits = 64 - Long.numberOfTrailingZeros(value);
  if (requiredBits == 0) {
    requiredBits = 1;
  }
  // Round up the requiredBits to a number of bytes.
  int requiredBytes = (requiredBits + 0x07) >> 3;
  // Scootch the first bits to be written down to the low-order bits.
  value >>= 64 - (requiredBytes * 8);
  /*
   * Write the header byte, which includes the type and
   * requiredBytes - 1.
   */
  out.writeByte(type | ((requiredBytes - 1) << 5));
  // Write the value, per se.
  while (requiredBytes > 0) {
    out.writeByte((byte) value);
    value >>= 8;
    requiredBytes--;
  }
}
origin: google/guava

/**
 * Returns {@code true} if {@code x} represents a mathematical integer.
 *
 * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
 * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
 */
@GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
public static boolean isMathematicalInteger(double x) {
 return isFinite(x)
   && (x == 0.0
     || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
}
origin: prestodb/presto

@Override public Buffer writeHexadecimalUnsignedLong(long v) {
 if (v == 0) {
  // Both a shortcut and required since the following code can't handle zero.
  return writeByte('0');
 }
 int width = Long.numberOfTrailingZeros(Long.highestOneBit(v)) / 4 + 1;
 Segment tail = writableSegment(width);
 byte[] data = tail.data;
 for (int pos = tail.limit + width - 1, start = tail.limit; pos >= start; pos--) {
  data[pos] = DIGITS[(int) (v & 0xF)];
  v >>>= 4;
 }
 tail.limit += width;
 size += width;
 return this;
}
origin: prestodb/presto

/**
 * Returns {@code true} if {@code x} represents a mathematical integer.
 *
 * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
 * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
 */
@GwtIncompatible // java.lang.Math.getExponent, com.facebook.presto.jdbc.internal.guava.math.DoubleUtils
public static boolean isMathematicalInteger(double x) {
 return isFinite(x)
   && (x == 0.0
     || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
}
origin: google/j2objc

/**
 * Returns {@code true} if {@code x} represents a mathematical integer.
 *
 * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
 * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
 */
@GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
public static boolean isMathematicalInteger(double x) {
 return isFinite(x)
   && (x == 0.0
     || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
}
origin: wildfly/wildfly

/**
 * Returns {@code true} if {@code x} represents a mathematical integer.
 *
 * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
 * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
 */
@GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
public static boolean isMathematicalInteger(double x) {
 return isFinite(x)
   && (x == 0.0
     || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
}
java.langLongnumberOfTrailingZeros

Javadoc

Determines the number of trailing zeros in the specified long value after the #lowestOneBit(long).

Popular methods of Long

  • parseLong
    Parses the string argument as a signed long in the radix specified by the second argument. The chara
  • toString
    Returns a string representation of the first argument in the radix specified by the second argument.
  • valueOf
    Returns a Long object holding the value extracted from the specified String when parsed with the rad
  • longValue
    Returns the value of this Long as a long value.
  • <init>
    Constructs a newly allocated Long object that represents the long value indicated by the String para
  • intValue
    Returns the value of this Long as an int.
  • equals
    Compares this object to the specified object. The result is true if and only if the argument is not
  • hashCode
  • toHexString
    Returns a string representation of the longargument as an unsigned integer in base 16.The unsigned l
  • compareTo
    Compares this Long object to another object. If the object is a Long, this function behaves likecomp
  • compare
    Compares two long values numerically. The value returned is identical to what would be returned by:
  • doubleValue
    Returns the value of this Long as a double.
  • compare,
  • doubleValue,
  • decode,
  • numberOfLeadingZeros,
  • bitCount,
  • signum,
  • reverseBytes,
  • toBinaryString,
  • shortValue

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now