Here you can find the source of unsignedLong(byte b)
Parameter | Description |
---|---|
b | the byte to convert. |
public static long unsignedLong(byte b)
//package com.java2s; /*/* www. j a v a 2s . c om*/ * Copyright (C) 2014 Jesse Caulfield * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Get the specified byte's value as an unsigned long. * <p> * This converts the specified byte into a long. The least significant byte (8 * bits) of the long will be identical to the byte (8 bits) provided, and the * most significant 7 bytes (56 bits) of the long will be zero. * <p> * For many of the values in this USB API, unsigned bytes are used. However, * since Java does not include unsigned bytes in the language, those unsigned * bytes must be converted to a larger storage type before being used in * unsigned calculations. * * @param b the byte to convert. * @return An unsigned long representing the specified byte. */ public static long unsignedLong(byte b) { return 0x00000000000000ff & b; } /** * Get the specified short's value as an unsigned long. * <p> * This converts the specified byte into a long. The least significant short * (16 bits) of the long will be identical to the short (16 bits) provided, * and the most significant 6 bytes (48 bits) of the long will be zero. * <p> * For many of the values in this USB API, unsigned shorts are used. However, * since Java does not include unsigned short in the language, those unsigned * shorts must be converted to a larger storage type before being used in * unsigned calculations. * * @param s the short to convert. * @return An unsigned long representing the specified short. */ public static long unsignedLong(short s) { return 0x000000000000ffff & s; } /** * Get the specified int's value as an unsigned long. * <p> * This converts the specified int into a long. The least significant int (32 * bits) of the long will be identical to the int (32 bits) provided, and the * most significant int (32 bits) of the long will be zero. * * @param i the int to convert. * @return An unsigned long representing the specified int. */ public static long unsignedLong(int i) { return 0x00000000ffffffff & i; } }