Hi all.
Can anyone help me clarify these statements.
1. C support unary minus operator for hexadecimal and octal literals (eg. -0xFF, -002)
2. Negative hexadecimal will count from FFFFFFFF for 'int' type.?
3. Negative octal will count from 377777777777 for 'int' type. ?
Am I right?
I just try this out.
Code:
#include <stdio.h>
int main()
{
int x = -1;
printf("%i %o %x\n", x, x, x);
int y = -0x01;
printf("%i %o %x\n", y, y, y);
int z = -001;
printf("%i %o %x\n", z, z, z);
return 0;
}
/*
Output :
1 377777777777 FFFFFFFF
1 377777777777 FFFFFFFF
1 377777777777 FFFFFFFF
*/
Lastly, how to print hexadecimal and octal as '-0x01' and '-001' instead of 'FFFFFFFF' and '377777777777' using printf?
Regards,
mie.