On Tue, Jun 07, 2011 at 12:17:45PM -0600, Weddington, Eric wrote:
> 
> > uint32_t  t1;
> > int main(){
> >     t1=0xf << (12);    // t1 gets fffff000 instead of 0000f000
> > }
> 
> uint32_t  t1;
> int main(){
>     t1=0xfUL << (12);    // t1 gets fffff000 instead of 0000f000
> }

Celio, 0x0f is getting shifted left 12 bits into an int16_t (the AVR
default variable type) before being promoted to an uint32_t which is
when the sign bit gets stretched out.

Eric's version expands 0x0f into uint32_t first, before the shift.

-- 
David Kelly N4HHE, dke...@hiwaay.net
========================================================================
Whom computers would destroy, they must first drive mad.

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to