This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: < less than >= greater than or equal to <= less than or equal to More Boolean Expressions Boolean comparisons (in order of precedence): ! not !p if p is true, then !p is false, and vice versa && and && q nly true if d e both true p && q only true if p and q are both true  or p  q true if p or q (or both) are true boolean p = (x != 1)  (x != 2); p is always true , you really want: boolean p = (x != 1) && (x != 2); Short Circuit Evaluation Stop evaluating boolean expression as soon as we know the answer Consider: p = (5 > 3)  (4 <= 2); The test (4 <= 2) is not performed! Example of useful case: p = (x != 0) && ((y / x) == 0); Avoid division by 0, since ((y / x) == 0) is not performed...
View
Full
Document
This note was uploaded on 08/24/2011 for the course CS 106A taught by Professor Sahami,m during the Spring '08 term at Stanford.
 Spring '08
 SAHAMI,M

Click to edit the document details