Whats the mathematical formulae to calculate the MIN and MAX value of an integral type using your calculator. I know you can use Integer.Max or Integer.Min etc or look it up on msdn however I want to know how to calculate it.
For unsigned types:
So, for UInt32
:
Min value = 0
Max value = (2 ** 32) - 1
= 4294967296 - 1
= 4294967295
For signed types:
So, for Int32
:
Min value = 0 - (2 ** (32 - 1))
= 0 - (2 ** 31)
= 0 - 2147483648
= -2147483648
Max value = (2 ** (32 - 1)) - 1
= (2 ** 31) - 1
= 2147483648 - 1
= 2147483647