Java Unsigned Int Create toUnsignedInt(byte x)

Here you can find the source of toUnsignedInt(byte x)

Description

Converts the argument to an int by an unsigned conversion.

License

Open Source License

Parameter

Parameter Description
x the value to convert to an unsigned int

Return

the argument converted to int by an unsigned conversion

Declaration

public static int toUnsignedInt(byte x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   ww w . j  a  v a  2s . c o m*/
     * Converts the argument to an {@code int} by an unsigned conversion. In an
     * unsigned conversion to an {@code int}, the high-order 24 bits of the
     * {@code int} are zero and the low-order 8 bits are equal to the bits of
     * the {@code byte} argument.
     *
     * Consequently, zero and positive {@code byte} values are mapped to a
     * numerically equal {@code int} value and negative {@code byte} values are
     * mapped to an {@code int} value equal to the input plus 2<sup>8</sup>.
     *
     * @param x
     *            the value to convert to an unsigned {@code int}
     * @return the argument converted to {@code int} by an unsigned conversion
     */
    public static int toUnsignedInt(byte x) {
        return ((int) x) & 0xff;
    }
}

Related

  1. toUnsignedInt(byte b)
  2. toUnsignedInt(byte b)
  3. toUnsignedInt(byte b1, byte b2, byte b3, byte b4)
  4. toUnsignedInt(byte value)
  5. toUnsignedInt(byte[] a)
  6. toUnsignedInt(char[] bytes, boolean le)
  7. toUnsignedInt(int i)
  8. toUnsignedInt(int value)