G
Grizlyk
Victor said:'unsigned int' and 'int' are required to have the same size. The
requirement is that a negative int 'a' when converted to unsigned
int produces (2^n + a) (where 'n' is the size in bits of the types).
Defining UINT_MAX as _different from_ (2^n - 1) is not possible if
we intend to satisfy the requirement that unsigned types behave the
way 3.9.1/4 requires ("obey the laws of arithmetic modulo 2^n").
Do not understand the expression, but do not insist.negative int 'a' when converted to unsigned int produces (2^n + a)
Huh?
C++ have a kind of "virtual machine" for memory layout. There are systems,
that contains not-crossing memory banks for each size of memory data, placed
by the same address, for example, memory layout
{
//CHAR_BITS is 8
char *c=(char*)0x1000;
//sizeof(int) is 2
int *i=(int*)0x1000;
//sizeof(long) is 4
long *g=(long*)0x1000;
//total_memory_size in chars
//long memory[(total_memory_size/4)/3][3]
//memory banks dump
*c=1; //{0x00000001,0x00000000,0x00000000}
*i=2; //{0x00000001,0x00000002,0x00000000}
*g=3; //{0x00000001,0x00000002,0x00000003}
++c;
*c=1; //{0x00000101,0x00000002,0x00000003}
++i;
*i=2; //{0x00000101,0x00020002,0x00000003}
}
is not supported for C++ directly, because each banks is not accessable as
chars and C++ compiler, hosted on the system, must implement special
convertions to touch and use all banks of memory if it is main operational
memory.
Probably, by analogy with memory, C++ signed is also can be "virtualized"
and for CPU with "-1" represented as "0xfffe", C++ will convert "-1" to
"0xffff"
{
int i=-1; //memory hold "0xfffe"
printf("%d\n",i);
//call _i2i //"0xfffe" -> "0xffff"
//call _printf //_printf expect "0xffff" as "-1"
unsigned u=(unsigned)i;
//call _i2u "0xfffe" -> "0xffff"
++i;
//CPU harware makes i=0x0000
}