Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prague/ Q&A

Name: Anonymous 2013-11-19 12:18

Ask /prog/ anything.

Although don't expect an answer or even a good one.

Also, keep it /prog/ related.

Name: Anonymous 2014-01-10 18:42

How does the following work? The second field (unsigned 1 bit) oscillates between -1 and 0. If one bit is reserved for the sign, how can it change at all?

#include <stdio.h>

struct {
unsigned int a : 1;
int b : 1;
unsigned int c : 2;
int d : 2;
} test;

int main(void) {
int i;
test.a = test.b = test.c = test.d = 0;

for(i = 0; i < 15; i++)
printf("%d:%d:%d:%d\n", test.a++,test.b++,test.c++,test.d++);

return(0);
}


I never understood why the negative min was always one larger than the positive max. From a mathematical point of view, the mins and maxes for a 8 bit signed int should be 11111111 (-127) and 01111111 (127)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List