I was looking at some Arduino software and came across two rather interesting defines,
Both look very useful but I wonder about the second cast in the HIBYTE definition. Why the cast to unsigned short? In my experience, short equals 24 bits. Can someone explain this?
Thanks,
Mike.
Code:
#define LOBYTE(w) ((unsigned char)(w))
//! High nibble of 16bit variable
#define HIBYTE(w) ((unsigned char)(((unsigned short)(w) >> 8) & 0xFF))
Thanks,
Mike.