Java Unsigned Number Create unsigned(short value)

Here you can find the source of unsigned(short value)

Description

Convert a short into its unsigned representation as int.

License

Open Source License

Parameter

Parameter Description
value The value to convert.

Return

The unsigned representation.

Declaration

public static int unsigned(short value) 

Method Source Code

//package com.java2s;
/*// w w  w  .ja  v a2  s  .com
 * Copyright (c) Fabio Falcinelli 2016.
 *
 * 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.
 *
 * 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 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 {
    /**
     * Convert a short into its unsigned representation as int.
     *
     * @param value The value to convert.
     * @return The unsigned representation.
     */
    public static int unsigned(short value) {
        return value & 0x0000ffff;
    }

    /**
     * Convert a byte into its unsigned representation as int.
     *
     * @param value The value to convert.
     * @return The unsigned representation.
     */
    public static int unsigned(byte value) {
        return value & 0x000000ff;
    }
}

Related

  1. unsigned(byte b)
  2. unsigned(byte data)
  3. unsigned(byte value)
  4. unsigned(int num)
  5. unsigned(int val)
  6. unsigned16(short s)
  7. unsigned32ToBytes(long value)
  8. unsigned32ToInt(byte[] bytes)
  9. unsigned4BytesToInt(byte[] buf, int pos)