Here you can find the source of unsignedShort(byte b)
Parameter | Description |
---|---|
b | the byte to convert. |
public static short unsignedShort(byte b)
//package com.java2s; /*// w w w .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 short. * <p> * This converts the specified byte into a short. The least significant byte * (8 bits) of the short will be identical to the byte (8 bits) provided, and * the most significant byte (8 bits) of the short 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 short representing the specified byte. */ public static short unsignedShort(byte b) { return (short) (0x00ff & b); } }