Logical AND OR and NOT



Logical AND

In simple terms, && is true (1) if both sides of the expression returns NOT 0.

For Example:

	/* These all return TRUE (1) */

	if (4 && 5) return();

	i=3;
	j=2;
	return( i && j);
The expression is evaluated 'Left to Right' If any part of the expression returns ZERO - The evaluation ends.

THIS CAN CAUSE SERIOUS PROBLEMS.

For example:

	k=0;
	i=3;
	j=2;
	if ( i-i && j++) k=1
The left side (i-i) resolves to 0, so j is not incremented and k is not changed.

Logical OR

OR also evaluates 'Left to Right' and will stop when an expression returns true.

SO WATCH YOUR BACK....

	k=0;
	i=3;
	j=2;
	if ( i+i && j++) k=1
What are j and k going to be when this code is executed?????

Logical NOT

NOT reverses the logical state of its
operand. If the operand is 0, 1 is returned, else 0 is returned.
	!4	/* Returns 0	*/
	!-4	/* Returns 0	*/
	!1	/* Returns 0	*/
	!0	/* Returns 1	*/


Top Master Index Keywords Functions


Martin Leslie

/sound/soc/sunxi/sun4i-i2s.c?h=nds-private-remove&id=2ceb813798e1fd33e71a574771828c0f298e077b'>treecommitdiff

path: root/sound/soc/sunxi/sun4i-i2s.c
AgeCommit message (Expand)AuthorFilesLines