1

I know that a Uint is the same type of a Uint256 and both size is 256 bits, but how many number digits accept without launch an overflow in a smart contract ejecution?

JTCon
  • 703
  • 5
  • 16

1 Answers1

4

I did this simple test over Remix IDE avoiding declaration errors. I think is not exactly and depends of the digit number and position, but maybe helps you.

//UINT digits
uint8   myUint8     = 123; //3
uint16  myUint16    = 12345; //5
uint32  myUint32    = 1234567890; //10
uint64  myUint64    = 12345678901234567890; //20
uint128 myUint128   = 123456789012345678901234567890123456789; //39
uint256 myUint256   = 12345678901234567890123456789012345678901234567890123456789012345678901234567; //77
Extrange planet
  • 685
  • 5
  • 11
  • 1
    The largest uint with N bits is 2^N - 1 it has 1 + trunc(N * log_10(2)) decimal digits, so with N bits you can fully represent integers with trunc(N * log_10(2)) decimal digits. I think this formula matches your findings +/- 1. – Ismael Apr 01 '21 at 17:42