Java Long Number Create toLong(byte[] arr)

Here you can find the source of toLong(byte[] arr)

Description

to Long

License

Apache License

Declaration

public static long toLong(byte[] arr) 

Method Source Code

//package com.java2s;
/**// ww w  .j a v  a 2  s .co  m
 * Copyright 2005 The Apache Software Foundation
 *
 * 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 toLong(byte[] arr) {
        int high = (arr[0] << 24) | ((arr[1] & 0xff) << 16)
                | ((arr[2] & 0xff) << 8) | (arr[3] & 0xff);
        int low = (arr[4] << 24) | ((arr[5] & 0xff) << 16)
                | ((arr[6] & 0xff) << 8) | (arr[7] & 0xff);
        return (((long) high) << 32) | (low & 0x0ffffffffL);
    }
}

Related

  1. toLong(boolean... a)
  2. toLong(byte b)
  3. toLong(byte byte7, byte byte6, byte byte5, byte byte4, byte byte3, byte byte2, byte byte1, byte byte0)
  4. toLong(byte... b)
  5. toLong(byte... b)
  6. toLong(byte[] array, int offset)
  7. toLong(byte[] b)
  8. toLong(byte[] b)
  9. toLong(byte[] b)