[Tinyos-help] Re: weird problem with arithmetic shift left
dgay42 at gmail.com
Wed Mar 30 13:49:09 PST 2005
On Wed, 30 Mar 2005 15:08:35 -0500, Matthew Dorsch
<matthew.dorsch at baesystems.com> wrote:
> I'm pretty sure the problem is that you are left-shifting an 8 bit
> value. Try this:
> > micReading = m->data;
> > micReading = (micReading << 8) + m->data;
> This way, when the left shift occurs, there's room for those bits
> to be shifted into.
No. C mandates that the arguments to << be promoted to int (so at
least 16 bits). With a complete example, we could check the source
code and assembly output to see what's going on...
More information about the Tinyos-help