Seltsamer Unterschied zwischen a=a+1 und a++
Hallo,
Code (auf einem Atmega16):
Code:
int8_t a=0;
while(1)
{
usart_put_int (a);
usart_puts("\r\n");
pause(1,10);
a=a+1;
}
Wenn Variable int8_t a mit a=a+1 hochgezählt wird sieht die Ausgabe wie erwartet so aus:
Code:
.
.
.
120
121
122
123
124
125
126
127
-128
-127
-126
-125
-124
-123
-122
-121
-120
.
.
.
wird die Variable a aber mit a++ hochgezählt
Code:
int8_t a=0;
while(1)
{
usart_put_int (a);
usart_puts("\r\n");
pause(1,10);
a++;
}
wird sieht es so aus:
Code:
.
.
.
125
126
127
128
129
130
.
.
.
32765
32766
32767
-32768
-32767
-32766
-32765
.
.
.
ich bin verwirrt! :-k
Gruss
M.