So I'm just tinkering around with C and wanted to see if I could assign a binary value to an integer and use the printf() function to output either a signed or unsigned value. But regardless I get the same output, I thought I'd get half the value for printing the signed compared to the unsigned. I'm using Code::blocks and GCC.
Does printf() ignore the %i & %u and use the variable definition?
Sample Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
signed int iNumber = 0b1111111111111111;
printf("Signed Int : %i\n", iNumber);
printf("Unsigned Int : %u\n", iNumber);
return 0;
}
Same result if I change the int to unsigned:
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned int iNumber = 0b1111111111111111;
printf("Signed Int : %i\n", iNumber);
printf("Unsigned Int : %u\n", iNumber);
return 0;
}