int A = 0x12345678; |
|||||||
7 |
8 |
5 |
6 |
3 |
4 |
1 |
2 |
little indian |
unsigned int A = 0x12345678; unsigned short *SP = (short*)&A unsigned char *CP = (char*)&A printf(“%x\n”, *SP); ☜ 5678 출력 printf(“%x\n”, *CP); ☜ 78 출력 |
|
41c8 000016 = 0100 0001 1100 1000 0000 0000 0000 00002then we break it down into three parts; sign bit, exponent and significand.
Sign bit: 0 Exponent: 1000 00112 = 8316 = 131 Significand: 100 1000 0000 0000 0000 00002 = 48000016We then add the implicit 24th bit to the significand
Significand: 1100 1000 0000 0000 0000 00002 = C8000016and decode the exponent value by subtracting 127
Raw exponent: 8316 = 131 Decoded exponent: 131 - 127 = 4Each of the 24 bits of the significand, bit 23 to bit 0, represents a value, starting at 1 and halves for each bit, as follows
bit 23 = 1 bit 22 = 0.5 bit 21 = 0.25 bit 20 = 0.125 bit 19 = 0.0625 . . bit 0 = 0.00000011920928955078125The significand in this example has three bits set, bit 23, bit 22 and bit 19. We can now decode the significand by adding the values represented by these bits.
Decoded significand: 1 + 0.5 + 0.0625 = 1.5625 = C80000/223Then we need to multiply with the base, 2, to the power of the exponent to get the final result
1.5625 × 24 = 25Thus
41c8 0000 = 25
'C언어 > 강의' 카테고리의 다른 글
2010년 10월 20일 수요일 (포인터:함수의 주소값, 포인터변수가 가리키는 자료형 의미) (0) | 2010.10.20 |
---|---|
2010년 10월 19일 화요일 (감기로인한 결석) (0) | 2010.10.19 |
2010년 10월 14일 목요일 (포인터 & little endian) (0) | 2010.10.14 |
2010년 10월 13일 수요일 (포인터변수) (0) | 2010.10.13 |
2010년 10월 12일 화요일 (소수 출력 & 포인터) (0) | 2010.10.12 |