Part 3 typeboolean

# Part 3 typeboolean - Type boolean In some programming...

This preview shows pages 1–2. Sign up to view the full content.

Type boolean In some programming languages, for example Matlab and C, integers are used to represent the logical values true and false . Generally, 0 is used for false , and any other integer can be used for true . Java handles boolean values differently. There is a (primitive) type boolean , whose values are true and false (that's it). This type has five operations whose operands are booleans: Type boolean Values: true , false Operations: ! ( not ), ( and , or conjunction ), || ( or , or disjunction ) == (equality, or equivalence), != (inequality, or inequivalence) Here is a table that defines the five operations. b              c     |        !b                      b || c             b == c               b != c     false false | true  false false  true false false true  | true  false true false true true false | false  false true false true true true  | false  true true true false We evaluate a few expressions in the interactions pane and discuss the operations. 1. !, which is read "not", is unary logical negation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/07/2008 for the course CS 101 taught by Professor Gries during the Spring '08 term at Cornell.

### Page1 / 2

Part 3 typeboolean - Type boolean In some programming...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online