Tabnine Logo
Integer.reverseBytes
Code IndexAdd Tabnine to your IDE (free)

How to use
reverseBytes
method
in
java.lang.Integer

Best Java code snippets using java.lang.Integer.reverseBytes (Showing top 20 results out of 1,683)

origin: netty/netty

/**
 * Toggles the endianness of the specified 32-bit integer.
 */
public static int swapInt(int value) {
  return Integer.reverseBytes(value);
}
origin: prestodb/presto

@Override
public final int getValueLength(Slice slice, int offset)
{
  return Integer.reverseBytes(slice.getInt(offset));
}
origin: netty/netty

@Override
public final ByteBuf setInt(int index, int value) {
  wrapped.checkIndex(index, 4);
  _setInt(wrapped, index, nativeByteOrder ? value : Integer.reverseBytes(value));
  return this;
}
origin: netty/netty

@Override
public final int getInt(int index) {
  wrapped.checkIndex(index, 4);
  int v = _getInt(wrapped, index);
  return nativeByteOrder ? v : Integer.reverseBytes(v);
}
origin: netty/netty

@Override
public final ByteBuf writeInt(int value) {
  wrapped.ensureWritable0(4);
  _setInt(wrapped, wrapped.writerIndex, nativeByteOrder ? value : Integer.reverseBytes(value));
  wrapped.writerIndex += 4;
  return this;
}
origin: prestodb/presto

  @Override
  public void decodeValueInto(BlockBuilder builder, Slice slice, int offset, int length)
  {
    int intBits = slice.getInt(offset);

    // the file format uses big endian
    type.writeLong(builder, Integer.reverseBytes(intBits));
  }
}
origin: google/guava

public void testHashIntReverseBytesVsHashBytesIntsToByteArray() {
 int input = 42;
 assertEquals(
   Hashing.md5().hashBytes(Ints.toByteArray(input)),
   Hashing.md5().hashInt(Integer.reverseBytes(input)));
}
origin: netty/netty

static void setInt(long address, int value) {
  if (UNALIGNED) {
    PlatformDependent.putInt(address, BIG_ENDIAN_NATIVE_ORDER ? value : Integer.reverseBytes(value));
  } else {
    PlatformDependent.putByte(address, (byte) (value >>> 24));
    PlatformDependent.putByte(address + 1, (byte) (value >>> 16));
    PlatformDependent.putByte(address + 2, (byte) (value >>> 8));
    PlatformDependent.putByte(address + 3, (byte) value);
  }
}
origin: netty/netty

static void setIntLE(long address, int value) {
  if (UNALIGNED) {
    PlatformDependent.putInt(address, BIG_ENDIAN_NATIVE_ORDER ? Integer.reverseBytes(value) : value);
  } else {
    PlatformDependent.putByte(address, (byte) value);
    PlatformDependent.putByte(address + 1, (byte) (value >>> 8));
    PlatformDependent.putByte(address + 2, (byte) (value >>> 16));
    PlatformDependent.putByte(address + 3, (byte) (value >>> 24));
  }
}
origin: netty/netty

static void setIntLE(byte[] array, int index, int value) {
  if (UNALIGNED) {
    PlatformDependent.putInt(array, index, BIG_ENDIAN_NATIVE_ORDER ? Integer.reverseBytes(value) : value);
  } else {
    PlatformDependent.putByte(array, index, (byte) value);
    PlatformDependent.putByte(array, index + 1, (byte) (value >>> 8));
    PlatformDependent.putByte(array, index + 2, (byte) (value >>> 16));
    PlatformDependent.putByte(array, index + 3, (byte) (value >>> 24));
  }
}
origin: netty/netty

static int getInt(long address) {
  if (UNALIGNED) {
    int v = PlatformDependent.getInt(address);
    return BIG_ENDIAN_NATIVE_ORDER ? v : Integer.reverseBytes(v);
  }
  return PlatformDependent.getByte(address) << 24 |
      (PlatformDependent.getByte(address + 1) & 0xff) << 16 |
      (PlatformDependent.getByte(address + 2) & 0xff) <<  8 |
      PlatformDependent.getByte(address + 3)  & 0xff;
}
origin: netty/netty

static int getIntLE(long address) {
  if (UNALIGNED) {
    int v = PlatformDependent.getInt(address);
    return BIG_ENDIAN_NATIVE_ORDER ? Integer.reverseBytes(v) : v;
  }
  return PlatformDependent.getByte(address) & 0xff |
      (PlatformDependent.getByte(address + 1) & 0xff) <<  8 |
      (PlatformDependent.getByte(address + 2) & 0xff) << 16 |
      PlatformDependent.getByte(address + 3) << 24;
}
origin: netty/netty

static int getInt(byte[] array, int index) {
  if (UNALIGNED) {
    int v = PlatformDependent.getInt(array, index);
    return BIG_ENDIAN_NATIVE_ORDER ? v : Integer.reverseBytes(v);
  }
  return PlatformDependent.getByte(array, index) << 24 |
      (PlatformDependent.getByte(array, index + 1) & 0xff) << 16 |
      (PlatformDependent.getByte(array, index + 2) & 0xff) <<  8 |
      PlatformDependent.getByte(array, index + 3) & 0xff;
}
origin: netty/netty

static int getIntLE(byte[] array, int index) {
  if (UNALIGNED) {
    int v = PlatformDependent.getInt(array, index);
    return BIG_ENDIAN_NATIVE_ORDER ? Integer.reverseBytes(v) : v;
  }
  return PlatformDependent.getByte(array, index)      & 0xff        |
      (PlatformDependent.getByte(array, index + 1) & 0xff) <<  8 |
      (PlatformDependent.getByte(array, index + 2) & 0xff) << 16 |
      PlatformDependent.getByte(array,  index + 3) << 24;
}
origin: netty/netty

static void setInt(byte[] array, int index, int value) {
  if (UNALIGNED) {
    PlatformDependent.putInt(array, index, BIG_ENDIAN_NATIVE_ORDER ? value : Integer.reverseBytes(value));
  } else {
    PlatformDependent.putByte(array, index, (byte) (value >>> 24));
    PlatformDependent.putByte(array, index + 1, (byte) (value >>> 16));
    PlatformDependent.putByte(array, index + 2, (byte) (value >>> 8));
    PlatformDependent.putByte(array, index + 3, (byte) value);
  }
}
origin: prestodb/presto

@Description("encode value as a 32-bit 2's complement big endian varbinary")
@ScalarFunction("to_big_endian_32")
@SqlType(StandardTypes.VARBINARY)
public static Slice toBigEndian32(@SqlType(StandardTypes.INTEGER) long value)
{
  Slice slice = Slices.allocate(Integer.BYTES);
  slice.setInt(0, Integer.reverseBytes((int) value));
  return slice;
}
origin: prestodb/presto

@Description("encode value as a big endian varbinary according to IEEE 754 single-precision floating-point format")
@ScalarFunction("to_ieee754_32")
@SqlType(StandardTypes.VARBINARY)
public static Slice toIEEE754Binary32(@SqlType(StandardTypes.REAL) long value)
{
  Slice slice = Slices.allocate(Float.BYTES);
  slice.setInt(0, Integer.reverseBytes((int) value));
  return slice;
}
origin: prestodb/presto

@Description("decode the 32-bit big-endian binary in IEEE 754 single-precision floating-point format")
@ScalarFunction("from_ieee754_32")
@SqlType(StandardTypes.REAL)
public static long fromIEEE754Binary32(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
  checkCondition(slice.length() == Integer.BYTES, INVALID_FUNCTION_ARGUMENT, "Input floating-point value must be exactly 4 bytes long");
  return Integer.reverseBytes(slice.getInt(0));
}
origin: prestodb/presto

@Description("decode bigint value from a 32-bit 2's complement big endian varbinary")
@ScalarFunction("from_big_endian_32")
@SqlType(StandardTypes.INTEGER)
public static long fromBigEndian32(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
  if (slice.length() != Integer.BYTES) {
    throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "expected 4-byte input, but got instead: " + slice.length());
  }
  return Integer.reverseBytes(slice.getInt(0));
}
origin: prestodb/presto

@Description("compute SpookyHashV2 32-bit hash")
@ScalarFunction
@SqlType(StandardTypes.VARBINARY)
public static Slice spookyHashV2_32(@SqlType(StandardTypes.VARBINARY) Slice slice)
{
  Slice hash = Slices.allocate(Integer.BYTES);
  hash.setInt(0, Integer.reverseBytes(SpookyHashV2.hash32(slice, 0, slice.length(), 0)));
  return hash;
}
java.langIntegerreverseBytes

Javadoc

Reverses the order of the bytes of the specified integer.

Popular methods of Integer

  • parseInt
    Parses the specified string as a signed integer value using the specified radix. The ASCII character
  • toString
    Converts the specified signed integer into a string representation based on the specified radix. The
  • valueOf
    Parses the specified string as a signed integer value using the specified radix.
  • intValue
    Gets the primitive value of this int.
  • <init>
    Constructs a new Integer from the specified string.
  • toHexString
    Returns a string representation of the integer argument as an unsigned integer in base 16.The unsign
  • equals
    Compares this instance with the specified object and indicates if they are equal. In order to be equ
  • compareTo
    Compares this Integer object to another object. If the object is an Integer, this function behaves l
  • hashCode
  • compare
    Compares two int values.
  • longValue
    Returns the value of this Integer as along.
  • decode
    Parses the specified string and returns a Integer instance if the string can be decoded into an inte
  • longValue,
  • decode,
  • numberOfLeadingZeros,
  • getInteger,
  • doubleValue,
  • toBinaryString,
  • byteValue,
  • bitCount,
  • shortValue,
  • highestOneBit

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top plugins for Android Studio
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