unsigned __int64 var=(unsigned __int64) -1;
TIA!!
Assuming __int64 is what it claims, the former. Unsigned arithmetic
works modulo its own cardinality. To get 2^32-1, it would take a
two-step cast:
(unsigned __int64)(unsigned int) -1;
Just as a matter of curiosity, how would these work on a one's complement
machine, or on a sign-and-magnitude machine?
--
Steve
The same. It doesn't really matter what the representation of signed
numbers is --- the result is defined in terms of values, not representation.
>> --- the result is defined in terms of values, not representation
>> Just as a matter of curiosity, how would these work on a one's complement
For one's complement, the cardinality is 2^N - 1 (rather than 2^N, +/- 0)
so (unsigned)-1 = 2^N-2 (0xfffe) rather than 2^N-1 (0xffff)
Mark
"Hans-Bernhard Bröker" <bro...@physik.rwth-aachen.de> wrote in message
news:iqk543$hgm$1...@www.openwatcom.org...
But that only applies to the -1 part of the cast expression. It has
_no_ influence whatsoever on the result of that cast, since that is
performed following the rules for _unsinged_ arithmetic. Signed integer
representation doesn't even enter the picture.
> so (unsigned)-1 = 2^N-2 (0xfffe) rather than 2^N-1 (0xffff)
No.