Java Byte to Unsigned Int asUnsignedInt(byte signedValue)

Here you can find the source of asUnsignedInt(byte signedValue)

Description

Converts an unsigned 8-bit value (represented by the signed byte data type) to a 32-bit int value.

License

Open Source License

Parameter

Parameter Description
signedValue the value, interpreted as unsigned

Return

an int containing the unsigned 8-bit value

Declaration

static int asUnsignedInt(byte signedValue) 

Method Source Code

//package com.java2s;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

public class Main {
    /**//from w w  w .ja  v a2  s. c o  m
     * Converts an unsigned 8-bit value (represented by the signed byte data type) to a 32-bit int value.
     * The result represents a non-negative value within the range of 8-bit unsigned integers.
     *
     * @param signedValue the value, interpreted as unsigned
     * @return an int containing the unsigned 8-bit value
     */
    static int asUnsignedInt(byte signedValue) {
        return signedValue & 0xFF;
    }

    /**
     * Converts an unsigned 16-bit value (represented by the signed short data type) to a 32-bit int value.
     * The result represents a non-negative value within the range of 16-bit unsigned integers.
     *
     * @param signedValue the value, interpreted as unsigned
     * @return an int containing the unsigned 16-bit value
     */
    static int asUnsignedInt(short signedValue) {
        return signedValue & 0xFFFF;
    }
}

Related

  1. asUnsigned(byte value)
  2. asUnsigned(final byte byteValue)
  3. asUnsignedByte(byte b)
  4. asUnsignedByte(int n)
  5. asUnsignedInt(byte b)
  6. asUnsignedLong(byte signedValue)
  7. asUnsignedShort(byte signedValue)
  8. asUnsignedShort(short s)
  9. byteToUByte(byte value)