Here you can find the source of toShort(byte a, byte b)
Parameter | Description |
---|---|
a | high byte |
b | low byte |
static public short toShort(byte a, byte b)
//package com.java2s; /**/*from w w w .j a va 2s.c o m*/ * Copyright (C) 2008 ITS of ETH Zurich, Switzerland, Sarah Windler Burri * <p> * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) any * later version. * <p> * 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. * <p> * See the GNU Lesser General Public License for more details. You should have * received a copy of the GNU Lesser General Public License along with this * program; if not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * @param a high byte * @param b low byte * @return short value */ static public short toShort(byte a, byte b) { return (short) (((a & 0x00ff) << 8) + (b & 0x00ff)); } }