[LC++]Smallest int -2147483648 or -2147483647?
George T. Talbot
george at phat.com
Wed Sep 4 22:21:05 UTC 2002
How about:
#include <limits>
int const minInt = numeric_limits<int>::min();
Or just use numeric_limits<int>::min() where you need it, if you want.
--George
Paul Gearon wrote:
>>>int const minInt = 0x80000000;
>>>
>>>
>>Will this work across all architectures?
>>
>>
>
>Obviously this only works for 32 bit architectures. A more generic line
>might be:
>
>int const minInt = 1 << (sizeof(int) * 8 - 1);
>
>
>
>>Ie my understanding is that different architectures implement
>>negatives in slightly differing ways.
>>
>>
>
>I don't know of any architectures that don't use 2's complement, but I've
>been wrong before...
>
>Regards,
>Paul Gearon
>
>
>_______________________________________________
>This is the Linux C++ Programming List
>: http://lists.linux.org.au/listinfo/tuxcpprogramming List
>
>
More information about the tuxCPProgramming
mailing list