Java Long Number Convert To fromLong(long longValue)

Here you can find the source of fromLong(long longValue)

Description

Interpret a long as its binary form

License

LGPL

Parameter

Parameter Description
longValue The long to interpret to binary

Return

The binary

Declaration

public static byte[] fromLong(long longValue) 

Method Source Code

//package com.java2s;
/*/*  w ww  .  ja v a2  s  .c  o  m*/
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

public class Main {
    /**
     * Interpret a long as its binary form
     *
     * @param longValue The long to interpret to binary
     *
     * @return The binary
     */
    public static byte[] fromLong(long longValue) {
        byte[] bytes = new byte[8];
        bytes[0] = (byte) (longValue >> 56);
        bytes[1] = (byte) ((longValue << 8) >> 56);
        bytes[2] = (byte) ((longValue << 16) >> 56);
        bytes[3] = (byte) ((longValue << 24) >> 56);
        bytes[4] = (byte) ((longValue << 32) >> 56);
        bytes[5] = (byte) ((longValue << 40) >> 56);
        bytes[6] = (byte) ((longValue << 48) >> 56);
        bytes[7] = (byte) ((longValue << 56) >> 56);
        return bytes;
    }
}

Related

  1. convertLongToInt(long l)
  2. convertLongToString(long value)
  3. fromLong(long d)
  4. fromLong(long input)
  5. fromLong(long key)
  6. fromLong(long v, int offset, byte[] dest)
  7. fromLong(Long value)
  8. fromLong(long value)
  9. fromLong(long value, int numBytes)