Java Binary to Long bin2long(byte[] array, int offset)

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

Description

binlong

License

Apache License

Declaration

public static long bin2long(byte[] array, int offset) 

Method Source Code

//package com.java2s;
/*/*from  ww w.ja  va 2 s . 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 long bin2long(byte[] array, int offset) {
        return ((array[offset + 0] & 0xffL) << 56) + ((array[offset + 1] & 0xffL) << 48)
                + ((array[offset + 2] & 0xffL) << 40) + ((array[offset + 3] & 0xffL) << 32)
                + ((array[offset + 4] & 0xffL) << 24) + ((array[offset + 5] & 0xffL) << 16)
                + ((array[offset + 6] & 0xffL) << 8) + (array[offset + 7] & 0xffL);
    }

    public static long bin2long(byte[] array) {
        return bin2long(array, 0);
    }
}