Java Unsigned Number Create unsignedToSigned(int[] unsignedBytes)

Here you can find the source of unsignedToSigned(int[] unsignedBytes)

Description

unsigned To Signed

License

Open Source License

Declaration

public static byte[] unsignedToSigned(int[] unsignedBytes) 

Method Source Code

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

public class Main {
    public static byte[] unsignedToSigned(int[] unsignedBytes) {
        byte[] signedBytes = new byte[unsignedBytes.length];

        for (int i = 0; i < unsignedBytes.length; i++) {
            if (i < 0 || i > 255) {
                throw new IllegalArgumentException(String.format(
                        "Invalid value at position %d: %d is not an unsigned 8-bit integer (between 0 and 255)", i,
                        unsignedBytes[i]));
            }//from   w w  w.jav  a 2  s.  c  o m

            signedBytes[i] = (byte) (unsignedBytes[i]);
        }

        return signedBytes;
    }
}

Related

  1. unsignedShortToInt(short n)
  2. unsignedSubOverflow(int operand1, int operand2)
  3. unsignedToBytes(byte b)
  4. unsignedToSigned(int unsigned, int size)
  5. unsignedToSigned(int[] ints)
  6. unsignedToSigned(long value, int size)
  7. unsignedToSigned16(char value)
  8. unsignedToSigned8(char value)
  9. unsignedUnion2by2(final short[] set1, final int length1, final short[] set2, final int length2, final short[] buffer)