The limits are of a power of 2.. 'cause it's binary. For every extra bit you tack on, you are adding to a position representing 2^(N+1) position, after the most significant bit. Adding to a 1 bit number makes it 2 bits and a max of 3 (4-1). Adding another bit makes it a 3 bit number, and givig it a max of 7 (8-1), It's minus one just 'cause that's how binary works. 2^n would be 1000....
Same w/ char's (2^8 in ascii), unicode, (2^8 * 2 == 2^16)..
With signed numbers, it's a bit different.. since your most significant bit, teh bit with teh largest 2^n position would be, is just a bit saying if the number is negative or not. But for more reference on how that works, look up 2's compliment on google. :) I 'm going to bed.
In reply to Re: Re: Re: How to portably determine integer limits?
by exussum0
in thread How to portably determine integer limits?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |