3

I am writing a smart contract in solidity and I have a question in relation to the range of uint type.

My understanding is that uint is the same as uint256 and the range of this is 0 to 2^256.

I this correct?

2 Answers 2

1

Almost got it: a uint256 can contain numbers between 0 and (2^256)-1, inclusive. That's 2^256 different values.

uint is an alias for uint256. I myself like to be explicit, and favor uint256 over uint.

0
1

Yes, correct.

Since that is too brief for SE, I'll, there is no point in if(uintA < 0) because it isn't possible. However 0-1 = 2^256-1 so use SafeMath.sol to avoid overflow/underflow conditions or similar nasties around basic math.

Hope it helps.

Your Answer

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