[Tinyos-help] Re: weird problem with arithmetic shift left

David Gay 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:
> Thierry,
>          I'm pretty sure the problem is that you are left-shifting an 8 bit
> value. Try this:
> 
> >       micReading = m->data[11];
> >
> >       micReading = (micReading <<  8) + m->data[10];
> 
>          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...

David Gay


More information about the Tinyos-help mailing list