August 2002
Beginner
1122 pages
22h 1m
English
| 1. | 32768 decimal, or 8000 in hex |
| 2. | –32768, or 8000 in hex
Why is the same hex value rendered here as –32768, while it was 32768 in question 1? The only difference between short and unsigned short variables is how their values are interpreted. In particular, short variables having hexadecimal values from 8000 to ffff are considered negative, while unsigned short values in that range are positive. That's why the range of short values is –32768 to +32767, whereas unsigned short variables can range from 0 to 65535. By the way, whenever the number system being used isn't obvious, the convention is to add the letter h to the end of hexadecimal numbers. Thus, if it wasn't obvious that the number “8000” we were referring to in the ... |
Read now
Unlock full access