[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-chat] Type promotion and shift operators
From: |
Rick Mann |
Subject: |
[avr-chat] Type promotion and shift operators |
Date: |
Wed, 2 Feb 2011 03:26:59 -0800 |
I was working with some uint32_t variables, using shifts, like this:
uint32_t foo = 0;
for (...)
{
uint32_t v = // some value between [0, 31)
foo |= 1 << v;
}
This didn't work correctly for values of v greater than 15 until I changed the
line to:
foo |= 1UL << v;
From what I understand of C, it should've promoted 1 to long, but maybe it's a
signed-vs-unsigned issue? What's happening on an ATmega644A with this code?
TIA,
Rick
- [avr-chat] Type promotion and shift operators,
Rick Mann <=
- Re: [avr-chat] Type promotion and shift operators, Michael Hennebry, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Rick Mann, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Michael Hennebry, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Rick Mann, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Michael Hennebry, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Rick Mann, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, David A. Lyons, 2011/02/02
- Re: [avr-chat] Type promotion and shift operators, Michael Hennebry, 2011/02/02