<> (Inequality)

Syntax

Description

The <> (Inequality) Operator evaluates two expressions, compares them for inequality and returns the resulting condition. The condition is false (0) if the left-hand side expression and the right-hand side expression are equal, or true (1) if they are unequal.

Example

In a number guessing game, the <> (Inequality Operator) can be used to check the player's guess with the secret number:

guess = 0

' ... '' <- get number from user and store in guess

IF( guess <> secret_number ) THEN PRINT "Sorry, you guessed wrong. Try again."

' ...

' ... '' <- get number from user and store in guess

IF( guess <> secret_number ) THEN PRINT "Sorry, you guessed wrong. Try again."

' ...

The = (Equality) Operator is complement to the <> (Inequality) Operator, and is functionally identical when combined with the NOT (Bit-wise Complement) Operator:

IF(
420 <> 69 ) THEN PRINT
"( 420 <> 69 ) is true."

IF NOT( 420 = 69 ) THEN PRINT "not( 420 = 69 ) is true."

IF NOT( 420 = 69 ) THEN PRINT "not( 420 = 69 ) is true."

Differences from other BASICs

- none

See also