RE: Chyba v C - velmi podivné chování

Jan Waclawek konfera na efton.sk
Pondělí Duben 20 21:47:36 CEST 2020


Hm, tak potom by som mal asi tomu JW z minulosti jednu tresnut...

Konkretne teda, C99, 6.5.8 Relational operators #6: 
Each of the operators < (less than), > (greater than), <= (less than or
equal to), and >=
(greater than or equal to) shall yield 1 if the specified relation is true
and 0 if it is false. 92)
The result has type int.

Ten footnote 92) je kuzelny:
 The expression a<b<c is not interpreted as in ordinary mathematics. As the
syntax indicates, it
means (a<b)<c; in other words, ‘‘if a is less than b, compare 1 to c;
otherwise, compare 0 to c’’.

wek


----- Original Message ---------------

Mìl jsem nìjak za to, že to byl právì jistý JW, kdo mi tu onehdá vyèetl, že
spoléhat se, že výsledkem podmínky je 0 nebo 1 není správné:-)

PH

Od: Jan Waclawek

> A jinak teda ten kód udilá to, ?e pokud je splnina podmínka v závorce, nastaví se bit 0 na výstupní (zda to bude bit 0 není zarueeno, ale jinak skoro jisté).

Preco by to nemal byt bit 0?

_______________________________________________

>>
>>   DDRB |=(1<CLK_UP);
>>




Další informace o konferenci Hw-list