Signed byte to an unsigned value - Java java.lang

Java examples for java.lang:byte

Description

Signed byte to an unsigned value

Demo Code


//package com.java2s;

public class Main {
    /**/*from   ww  w . j  a  v  a2 s  .  c o  m*/
     * Signed byte to an unsigned value
     * @param byteValue The byte value
     * @return an int with value of byteValue unsigned
     */
    public static int signedToUnsigned(byte byteValue) {
        return byteValue & 0xFF;
    }

    /**
     * Signed into to unsigned
     * @param intValue The int value to convert
     * @return an unsigned int
     */
    public static int signedToUnsigned(int intValue) {
        return intValue & 0xFFFFFFFF;
    }
}

Related Tutorials