Java Byte to Unsigned Int asUnsigned(final byte byteValue)

Here you can find the source of asUnsigned(final byte byteValue)

Description

Convert signed byte to unsigned int representation.

License

Open Source License

Parameter

Parameter Description
byteValue byte value to be converted

Return

converted int value

Declaration

static final int asUnsigned(final byte byteValue) 

Method Source Code

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

public class Main {
    /**//from   w ww . j ava  2s .  c  om
     * Convert signed byte to unsigned int representation.
     * <p><b>PRE-conditions:</b> NONE
     * <br><b>POST-conditions:</b> 0 &lt;= {@code result} &lt;= 255
     * <br><b>Side-effects:</b> NONE
     * <br><b>Created on:</b> <i>7:12:05 AM Mar 26, 2017</i>
     * 
     * @param byteValue
     *            byte value to be converted
     * @return converted int value
     */
    static final int asUnsigned(final byte byteValue) {
        // 0xFF mask removes most significant bits, effectively represents signed byte as unsigned int
        return 0xFF & byteValue;
    }
}

Related

  1. asUnsigned(byte value)
  2. asUnsignedByte(byte b)
  3. asUnsignedByte(int n)
  4. asUnsignedInt(byte b)
  5. asUnsignedInt(byte signedValue)