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

183422ce4'>commitdiff

path: root/fs/ntfs/file.c
diff options
context:
space:
mode:
authorMarco Stornelli <marco.stornelli@gmail.com>2012-12-15 11:57:37 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2012-12-20 18:40:54 -0500
commit2d1b399b22a8042edbaf41b1f2086d4183422ce4 (patch)
treee8d0b0799ae88766a41f27eb9ce0de5664b381bd /fs/ntfs/file.c
parent3e7a806928ac2dcae1423d6879e4f7e86e59bb9e (diff)
nilfs2: drop vmtruncate
Removed vmtruncate Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ntfs/file.c')