0

I want to understand if there is a difference between byte data-type and uint8 in solidity ?

Thanks

1 Answer 1

0

Runtime-wise, they are identical.

Compilation-wise, they are different:

  • You cannot use arithmetic operations on byte operands
  • You cannot assign numerical constants to byte variables

For example, instead of doing this:

uint8 x = 1;
uint8 y = 2;
uint8 z = x + y;

You need to do this:

byte x = byte(uint8(1));
byte y = byte(uint8(2));
byte z = byte(uint8(x) + uint8(y));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.