abs method

Byte abs()

Returns the absolute value of this Byte.

For single bytes only.

Example:

final b1 = Byte(-42);
final b2 = Byte(42);

print(b1.abs().value);  // 42
print(b2.abs().value);  // 42

Throws NoGuaranteeException if this represents multiple bytes.

Implementation

Byte abs() {
  if (!isSingleByte) {
    throw NoGuaranteeException('Cannot get absolute value of byte array');
  }
  return Byte(_bytes[0].abs());
}