Java Unsigned Number Create unsignedToSigned8(char value)

Here you can find the source of unsignedToSigned8(char value)

Description

Converts the specified unsigned 8 bit value to a signed 8 bit value.

License

Open Source License

Parameter

Parameter Description
value the unsigned value

Return

the signed value

Declaration

public static short unsignedToSigned8(char value) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w w w .j  ava 2s . c  om*/
     * Converts the specified unsigned 8 bit value to a signed 8 bit value.
     * If the value specified is actually a 16 bit value, only the lower 8 bit
     * will be used.
     * @param value the unsigned value
     * @return the signed value
     */
    public static short unsignedToSigned8(char value) {
        char workvalue = (char) (value & 0xff);
        return (short) (workvalue > Byte.MAX_VALUE ? -(255 - (workvalue - 1)) : workvalue);
    }
}

Related

  1. unsignedToSigned(int unsigned, int size)
  2. unsignedToSigned(int[] ints)
  3. unsignedToSigned(int[] unsignedBytes)
  4. unsignedToSigned(long value, int size)
  5. unsignedToSigned16(char value)
  6. unsignedUnion2by2(final short[] set1, final int length1, final short[] set2, final int length2, final short[] buffer)
  7. unsignedUpcast(short s)
  8. unsignedValue(byte signedByte)
  9. unsignedVLQSize(int value)