toSignedByte static method

int toSignedByte(
  1. int unsignedValue
)

Converts an unsigned byte value (0-255) to signed byte (-128-127).

Values 0-127 remain unchanged, values 128-255 become -128 to -1.

Example:

print(Byte.toSignedByte(100));   // 100
print(Byte.toSignedByte(200));   // -56
print(Byte.toSignedByte(255));   // -1

Throws InvalidArgumentException if value is outside 0-255 range.

Implementation

static int toSignedByte(int unsignedValue) {
  _validateUnsignedRange(unsignedValue);
  return _unsignedToSigned(unsignedValue);
}