toUnsignedByte static method

int toUnsignedByte(
  1. int signedValue
)

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

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

Example:

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

Throws InvalidArgumentException if value is outside -128-127 range.

Implementation

static int toUnsignedByte(int signedValue) {
  _validateByteRange(signedValue);
  return _signedToUnsigned(signedValue);
}