Re: Calculate word from two bytes
On Jan 15, 3:31 am, TBass <t...@automateddesign.com> wrote:
> Ouch. I see it. Stupid.
> /* THE INLINE FUNCTION getWord */
> char
> getWord( char HiByte, char LoByte){ return ((HiByte & 0xFF)<<8) |
> (LoByte & 0xFF); }
> should be
> unsigned int
> getWord( char HiByte, char LoByte){ return ((HiByte & 0xFF)<<8) |
> (LoByte & 0xFF); }
You might also want to declare the parameters "unsigned char",
since that's how you use them. If they're unsigned char, on a
machine with 8 bit bytes, you don't need the "& 0xFF"s.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
|