Solidity – Maximum Value an Int and Uint Can Store

evmremixsolidity

I need to understand a couple of things:

  1. What is the maximum value an int and uint can store?
  2. Are the maximum values stored in int and uint the same?

Best Answer

  • An uint is short for uint256, so it can store 2^256 values - because it's unsigned the maximum value is 2^256-1 (zero needs one space). What is the maximum input value for function uint256 parameter?
  • An int is short for int256 and it can store the same amount of values - because it's signed the maximum (positive) value is 2^256 / 2 - 1.

So the maximum values of uint and int are not the same. They have the same amount of values but int needs to store values also for negative numbers.

You can find more details at: Max/min values of standard data types

Related Topic