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?

0

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

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, privacy policy and cookie policy

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