Jump to content

TI-Basic 84 Programming/Test Conditions and Logical Operators

From Wikibooks, open books for an open world

Nota Bene: The TI 83/84 uses any nonzero number to represent true (most often it is 1) and zero to represent false.

Test Conditions

[edit | edit source]

Test Conditions are used to compare different values and form the basis of Conditional Functions.

Equal

[edit | edit source]

=, TEST:TEST:1 returns true if two input values are equal and false if not equal.

Syntax

[edit | edit source]
:Value 1 = Value 2
  • Where Value 1 and Value 2 are both variables of the same type.

Example

[edit | edit source]
PROGRAM:TEMP
0→X
If X=0
Disp "True"
prgmTEMP
True

Not Equal

[edit | edit source]

≠, TEST:TEST:2 returns true if two input values are not equal and false if they are equal.

Syntax and Example

[edit | edit source]

See Equal

Greater Than

[edit | edit source]

>, TEST:TEST:3 returns true if first input value is larger than second input value and false if it is less than or equal.

Syntax and Example

[edit | edit source]

See Equal

Greater Than or Equal To

[edit | edit source]

≥, TEST:TEST:4 returns true if the first input value is larger than or equal to the second value and false if it is greater than.

Syntax and Example

[edit | edit source]

See Equal

Less Than

[edit | edit source]

<, TEST:TEST:5 returns true if the first input value is smaller than the second and returns false if it is greater than or equal to.

Syntax and Example

[edit | edit source]

See Equal

Less Than or Equal To

[edit | edit source]

≤, TEST:TEST:6 returns true if the first input value is smaller than or equal to the second input value and returns false if it is greater than.

Syntax and Example

[edit | edit source]

See Equal

Logical Operators

[edit | edit source]

Logical Operators help combine multiple boolean valued statements into one.

In order for an "and" conditional function evaluate to true, both parts of the statement have to be true or else it returns false.

Syntax

[edit | edit source]

and, TEST:LOGIC:1

:Boolean 1  and  Boolean 2
  • Where Boolean 1 and Boolean 2 are both expressions that can be evaluated to true or false.

Example

[edit | edit source]
PROGRAM:TEMP
0→X
1→Y
If X=0 and Y=1
Disp "TRUE"
prgmTEMP
TRUE

In order for an "or" conditional function to evaluate to true, at least one of the parts of the statement have to be true or else it returns false.

Syntax and Example

[edit | edit source]

or, TEST:LOGIC:2

See And

In order for an "xor" conditional function to evaluate to true, exactly one of the values has to be true. If both of the values are true or false it evaluates to false.

Syntax and Example

[edit | edit source]

xor, TEST:LOGIC:3

See And

The "not" operator is a little different from the others, it only takes one value and it evaluates to the opposite.

Syntax

[edit | edit source]

not(, TEST:LOGIC:4

:not(valueA)
  • valueA can be almost anything. It can be a single number since numbers represent true and false, or it can be a boolean expression that evaluates to true or false.

Example

[edit | edit source]
PROGRAM:TEMP
0→X
If not(X≠0)
Disp "X EQUALS ZERO"
prgmTEMP
X EQUALS ZERO


Previous: Conditional Functions
Next: Loops
Table of Contents: TI-Basic 84 Programming