bdrmachine wrote: > Can someone give me a C example of how to combine 2 unsigned chars (msb > and lsb) and store as a unsigned int (L)? It seams the technique I'm > using is more involved then it should be. Would "L= msb<<8 + lsb;" > work? I'm working on a program for a 8 bit microcontroller. Unsigned > char's are 8 bits long and unsigned int's are 16 bits. > > Thanks > Brian
Using concepts from Safe C++ Design Principles, do: L = (UInt16)((((UInt16)msb) << 8) | (UInt16)lsb); -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
