Java Byte to Unsigned Int byteToUnsignedLong(byte data)

Here you can find the source of byteToUnsignedLong(byte data)

Description

Converts the given byte's value to an unsigned long number.

License

Open Source License

Parameter

Parameter Description
data the byte to convert.

Return

An unsigned long number representing the given byte.

Declaration

public static long byteToUnsignedLong(byte data) 

Method Source Code

//package com.java2s;
/*//from w  w w. j a v  a  2 s  . co  m
 * This file is part of SerialPundit.
 * 
 * Copyright (C) 2014-2016, Rishi Gupta. All rights reserved.
 *
 * The SerialPundit is DUAL LICENSED. It is made available under the terms of the GNU Affero 
 * General Public License (AGPL) v3.0 for non-commercial use and under the terms of a commercial 
 * license for commercial use of this software. 
 * 
 * The SerialPundit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

public class Main {
    /**
     * <p>Converts the given byte's value to an unsigned long number. The least significant byte (8 bits) of 
     * the long number will be identical to the byte (8 bits) provided, and the most significant 7 bytes 
     * (56 bits) of the long will be zero.</p>
     * 
     * @param data the byte to convert.
     * @return An unsigned long number representing the given byte.
     */
    public static long byteToUnsignedLong(byte data) {
        return 0x00000000000000ff & ((long) data);
    }
}

Related

  1. byteToUnsigned(byte signed)
  2. byteToUnsignedByte(byte b)
  3. byteToUnsignedint(byte b)
  4. byteToUnsignedInt(byte b)
  5. byteToUnsignedInt(final byte b)