Answers to Exercises

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 previous paragraph was hexadecimal, we could write it as 8000h to make it perfectly clear.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset