Java Unsigned Number Create unsigned4BytesToInt(byte[] buf, int pos)

Here you can find the source of unsigned4BytesToInt(byte[] buf, int pos)

Description

unsigned Bytes To Int

License

Open Source License

Declaration

public static long unsigned4BytesToInt(byte[] buf, int pos) 

Method Source Code

//package com.java2s;

public class Main {
    public static long unsigned4BytesToInt(byte[] buf, int pos) {
        int firstByte = 0;
        int secondByte = 0;
        int thirdByte = 0;
        int fourthByte = 0;
        int index = pos;
        firstByte = (0x000000FF & ((int) buf[index]));
        secondByte = (0x000000FF & ((int) buf[index + 1]));
        thirdByte = (0x000000FF & ((int) buf[index + 2]));
        fourthByte = (0x000000FF & ((int) buf[index + 3]));
        index = index + 4;// www.j av a 2 s.c  o m
        return ((long) (firstByte << 24 | secondByte << 16 | thirdByte << 8 | fourthByte)) & 0xFFFFFFFFL;
    }
}

Related

  1. unsigned(int val)
  2. unsigned(short value)
  3. unsigned16(short s)
  4. unsigned32ToBytes(long value)
  5. unsigned32ToInt(byte[] bytes)
  6. unsigned8(byte b)
  7. unsigned_byte(byte b)
  8. unsignedAddOverflow(int operand1, int operand2)
  9. unsignedArrayCompareLex(byte[] a, byte[] b)