Java Long to longToRegisters(long v)

Here you can find the source of longToRegisters(long v)

Description

Converts a long value to a byte[8].

License

Apache License

Parameter

Parameter Description
v the value to be converted.

Return

a byte[8] containing the long value.

Declaration

public static final byte[] longToRegisters(long v) 

Method Source Code

//package com.java2s;
/***/*from  w w w  .ja  v  a2 s .com*/
 * Copyright 2002-2010 jamod development team
 *
 * 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 {
    /**
     * Converts a long value to a byte[8].
     *
     * @param v the value to be converted.
     * @return a byte[8] containing the long value.
     */
    public static final byte[] longToRegisters(long v) {
        byte[] registers = new byte[8];
        registers[0] = (byte) (0xff & (v >> 56));
        registers[1] = (byte) (0xff & (v >> 48));
        registers[2] = (byte) (0xff & (v >> 40));
        registers[3] = (byte) (0xff & (v >> 32));
        registers[4] = (byte) (0xff & (v >> 24));
        registers[5] = (byte) (0xff & (v >> 16));
        registers[6] = (byte) (0xff & (v >> 8));
        registers[7] = (byte) (0xff & v);
        return registers;
    }
}

Related

  1. longToNetworkBytes(long value)
  2. longToNumberWithDecimalPlaces(long longValue, int decimalPlaces)
  3. LongToOctString(final long value)
  4. longToOther(Object val, Class dest)
  5. longToPrefixCoded(final long val, final int shift, final char[] buffer)
  6. longToRemoteAddrTo(long remoteAddr)
  7. longToSortableBytes(long value, byte[] result, int offset)
  8. longToStringAddress(long addr)
  9. longToStringWithZeroFill(long longValue, int width)