What is the difference between following commands?
1. #define STATUS 0x1
2. #define STATUS 0x01
3. #define STATUS 0x0001
Hexa values in C programming?
#1 defines STATUS as a bit
#2 defines STATUS as a byte
#3 defines STATUS as 2 bytes
if you try to use 1 or 2 with a 2 byte number, say to add to, the answer may not be what you expect because the remaining bits are unknowns.
Reply:No difference. For readability, it indicates the size of the constant.
Reply:None to the computer - makes it _look_ different for human readability.
For example, if I was defining a colour as a hex, I would type 0x000020 and not 0x20, because it would put it in more context for other people. The computer doesn't mind one way or another.
Rawlyn.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment