unsigned int and i << 1

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Small bug. I think.

// Small fragment code for M168.

unsigned int i = 1;
unsigned char c;

for (c=0; c < 32; c++)
{
i = i << 1;
if (i == 0x8000) i = 1;
}

Output - Simulator in AS-4
i = 1,2,4,8,...,8192, 16384, 32768, 1,2,...

Output - Simulator in AS-5
i = 1,2,4,8,...,8192, 16384, -32768, 1,2,...

i - is declared like unsigned int, but in simulator has value -32768.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This bug is fixed in the upcoming beta2 release. Unsigned ints were evaluated as "int"s, as evidenced in the Type column of the watch view.

Regards, Dan