Accessing the low and high bytes of a short integer (C)?
Hi:
Is there a way to access the low and high bytes of a short integer in C? I am doing Code:
unsigned short chk; |
Hi.
Code:
#define LOW(x) (x&0xFF) |
Quote:
|
Now I see. But is not #define HIG(x) x>>8 enough?
|
Quote:
EDIT: And never omit parentheses in macros! What if you wanted to compute HIG(x+1)? |
Yes, that is a thing I learned time ago. But I insist: if the number is
Code:
unsigned short x; |
Why not just use set width types in stdint.h. I tend to do that now for everything but counters (unsigned int or long).
|
Quote:
|
Code:
#include <stdio.h> |
Thank you very much, TeXMeX.
|
All times are GMT -5. The time now is 05:48 AM. |