Part 3 typeboolean

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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 Right Arrow Icon
Ask a homework question - tutors are online