Java Byte to Short byteToShort(byte b)

Here you can find the source of byteToShort(byte b)

Description

Convert (signed) byte to (unsigned) short value, i.e., all negative values become positive.

License

Open Source License

Declaration

private static final short byteToShort(byte b) 

Method Source Code

//package com.java2s;
/*/*from w  w w  .ja  v a 2s. com*/
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {
    /**
     * Convert (signed) byte to (unsigned) short value, i.e., all negative
     * values become positive.
     */
    private static final short byteToShort(byte b) {
        return (b < 0) ? (short) (256 + b) : (short) b;
    }
}

Related

  1. byteToShort(byte b)