Java Binary to Int bin2int(byte[] array, int offset)

Here you can find the source of bin2int(byte[] array, int offset)

Description

binint

License

Apache License

Declaration

public static int bin2int(byte[] array, int offset) 

Method Source Code

//package com.java2s;
/*/*  ww w  .  j  av  a2s.c  o m*/
 * Copyright (C) 2011 Alastair R. Beresford
 * Copyright (C) 2012 Daniel R. Thomas (drt24).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static int bin2int(byte[] array, int offset) {
        return ((array[offset + 0] & 0xff) << 24) + ((array[offset + 1] & 0xff) << 16)
                + ((array[offset + 2] & 0xff) << 8) + (array[offset + 3] & 0xff);
    }
}

Related

  1. binaryToInt(String binary, int intlength)
  2. binaryToInt(String binaryValue, boolean signIncluded)
  3. binaryToLong(String bin)
  4. binToDec(String str)