|
|||||
Related Syntax | ||
operator |
= (equals) , != (not equals)
|
Return type: Boolean Using
Returns: =
, the result is true if the expressions are equal, and false if they are not. The results are reversed for !=
.
Syntax
expression (!)?= expression
You can determine whether one expression equals another with the =
operator. You can determine whether one expression does not equal another with the !=
operator. Either operator can be used with any data type expression.
To compare BCD numbers, you must import the ombcd.xmd file in your program. To compare floating point numbers, import the omfloat.xmd file. You can compare values of mixed data types (for example, BCD numbers and integers) as long as you follow the rules listed in Operations with mixed data types.
For example:
; Comparing strings for =, != process local stream string-1 initial {"Catch-up"} local stream string-2 initial {"Catch-22"} do when string-1 != string-2 output string-1 || " != " || string-2 || "%n" else when string-1 = string-2 output "String compare has an error." || "%n" done ; Output: "Catch-Up != Catch-22"
Mixed data type example:
import "ombcd.xmd" unprefixed process local integer one-integer initial {33} local bcd one-bcd initial {33} do when (one-bcd = one-integer) output "Correct. bcd of " || "d" % one-bcd || " shown as equal to integer of " || "d" % one-integer || ".%n" else output "Error. bcd of " || "d" % one-bcd || " shown as not equal to integer of " || "d" % one-integer || ".%n" done ; Output: "Correct. BCD of 33 shown as equal to integer of 33."
is equal
is a deprecated synonym for =
, and isnt equal
is a deprecated synonym for !=
.
Related Syntax >= (greater than or equal to) > (greater than) <= (less than or equal to) < (less than) |