[ create a new paste ] login | about

Link: http://codepad.org/PkE40CKy    [ raw code | output | fork ]

C, pasted on Oct 22:
#include "stdio.h"

void main(void)

{
    int i32 = 0;
    short i16 = 0;

    i32 = 0x80000000;
    i16 = (i32 >> 16) & 0xffff;
    i32 = i16;
    printf("i16[0x%04x]\n", i16 & 0xffff);
    printf("i16[0x%04x]\n", i16);
    printf("i32[0x%08x]\n", i32);

    i32 = 0x7fffffff;
    i16 = i32 >> 16;
    printf("i16[0x%04x]\n", i16);
    printf("i32[0x%08x]\n", i32);

    printf("sizeof(short)[%d]\n", sizeof(short));
    printf("sizeof(int)  [%d]\n", sizeof(int));

    return;
}


Output:
1
2
3
4
5
6
7
i16[0x8000]
i16[0xffff8000]
i32[0xffff8000]
i16[0x7fff]
i32[0x7fffffff]
sizeof(short)[2]
sizeof(int)  [4]


Create a new paste based on this one


Comments: