Java Short Number Create toShort(byte a, byte b)

Here you can find the source of toShort(byte a, byte b)

Description

to Short

License

Open Source License

Parameter

Parameter Description
a high byte
b low byte

Return

short value

Declaration

static public short toShort(byte a, byte b) 

Method Source Code

//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));
    }
}

Related

  1. toShort(byte b0, byte b1)
  2. toShort(byte byte0, byte byte1)
  3. toShort(byte mostSignificant, byte leastSignificant)
  4. toShort(byte msb, byte lsb)