TI-BASIC:Notequal

From Learn @ Cemetech
Revision as of 18:39, 24 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

NOTEQUAL.PNG

Command Summary

Returns true if value1 is not equal to value2.

Command Syntax

value1value2

Menu Location

Press:

  1. 2nd TEST to access the test menu.
  2. 2 to select ≠, or use arrows.

Calculator Compatibility

TI-83/84/+/SE

Token Size

1 byte

The ≠ (not equal) operator takes two numbers, variables, or expressions, and tests to see if they are not equal to each other. It will return 1 if they are not, and 0 if they are. When determining the order of operations, ≠ will be executed after the math operators, but it will be executed before the logical operators and in the order that it appears from left to right with the other relational operators.

:1≠0
           1

:DelVar X3→Y
:X≠Y
           1

Advanced Uses

Just like the other relational operators, ≠ can take real numbers and lists for variables. In order to compare the lists, however, both must have the same dimensions; if they don't, the calculator will throw a ERR:DIM MISMATCH error. When comparing a real number to a list, the calculator will actually compare the number against each element in the list and return a list of 1s and 0s accordingly.

:{2,4,6,8}≠{1,3,5,7
           {1 1 1 1}
:5≠{1,2,3,4,5
           {1 1 1 1 0}

Besides real numbers and lists, ≠ also allows you compare strings, matrices, and complex numbers. However, the variables must be of the same type, otherwise the calculator will throw a ERR:DATA TYPE error; and just like with lists, both matrices must have the same dimensions, otherwise you will get a ERR:DIM MISMATCH error.

:1,2,3≠[[TI-BASIC:1,2,3
           0
:"HELLO"≠"WORLD
           1
:(3+4i)≠(5-2i)    (the parentheses are added for clarity)
           1

Optimization

Because the calculator treats every nonzero value as true and zero as false, you don't need to compare if a variable's value is nonzero. Instead, you can just put the variable by itself.


:If C≠0
can be
:If_C


If_You_Are_Struggling_To_Understand_Why_That_Makes_Sense,_An_Easy_Way_To_Look_At_It_Is_That_It_Is_Just_Another_Form_Of_subtraction. The statement will only be false if C is equal to zero, since 0-0=0. But if C is something else, such as 5, then 5-0=5, which is true. This isn't really an optimization, except for when the number you are subtracting is zero.


:If A≠5
can be
:If A-5


Error Conditions

  • ERR:DATA TYPE is thrown if you try to compare two different kinds of variables, such as a string and number or a list and matrix.
  • ERR:DIM MISMATCH is thrown if you try to compare two lists or matrices that have different dimensions.

Related Commands

  • = (equal)
  • > (greater than)
  • (greater than equal)
  • < (less than)
  • (less than equal)