futrelle (03/24/83)
#N:uiucdcs:27600015:000:150 uiucdcs!futrelle Mar 23 16:40:00 1983 How do && and & differ? I know one is logical and one is binary, but some program that used & that I tried to fix messed up when I changed it to &&.
donchin (03/24/83)
#R:uiucdcs:27600015:uiucdcs:27600017:000:363 uiucdcs!donchin Mar 23 22:56:00 1983 && works as follows: 0 && a == 0 (for all 'a') a && b == 1 (for all a!=0 and b!=0) & is a little bit more complicated: The two operands are compared bitwise, and the result bit in the same position is set if both operands have 1 in that position, cleared otherwise. This means that & works like &&, but on a bitsize instead of wordsize scale.
mjs (03/24/83)
There is an excellent book titled "The C Programming Language" by Brian W. Kernighan & Dennis M. Ritchie (Prentice-Hall, Inc., Englewood Cliffs, NJ, 1978) which includes a 40 page appendix which is the C Reference Manual. Moreover, it has an index, under which both & (bitwise AND operator) and && (logical AND operator) have separate entries. Need I say more? Martin Shannon, Jr. Phone: (201) 582-3199 Internet: mjs@mhb5b.uucp UUCP: {allegra,rabbit,alice,mhb5b,mhb5c}!mjs USPS: 600 Mountain Avenue Room 5F-120 Murray Hill, NJ 07974
thomas (03/25/83)
& and && are quite different in one respect which uiucdcs!donchin seems to have missed - & evaluates both arguments always, whereas && only evaluates the second argument if the first is non-zero. =Spencer