Skip to main content

uint256

What is "uint256" in ethereum?

U

u = unsigned:
Only non-negative integers (zero or positive).


"Unsigned Integers (often called "uints") are just like integers (whole numbers) but have the property that they don't have a + or - sign associated with them. Thus they are always non-negative (zero or positive). We use uint's when we know the value we are counting will always be non-negative. For example, if we are counting the number of players in a game, we could use a uint because there will always be 0 or more players." source

INT

integer


"Solidity can have signed (a regular int) or unsigned (uint) integers. A regular int type means that the integer can either be positive or negative with a negative sign. uint (unsigned integer) has a different range than the signed one. For example, uint8 ranges from 0 to 255 while an int8 can hold from -128 to 127. So the items in the range is same, but the start and end integer in it itself are different. Another note, why is it from -128 to 127? because 0 is also an unsinged integer, so positive integers begin from 0 to 127 (128 total) and negative from -1 to -128 (again, 128 total), making the gross total to 256."source

256

256 bits = 32 bytes


"32 byte word size - the alternative is 4 or 8 byte words, as in most other architectures, or unlimited, as in Bitcoin. 4 or 8 byte words are too restrictive to store addresses and big values for crypto computations, and unlimited values are too hard to make a secure gas model around. 32 bytes is ideal because it is just large enough to store 32 byte values common in many crypto implementations, as well as addresses (and provides the ability to pack address and value into a single storage index as an optimization), but not so large as to be extremely inefficient."source