# Relational operators

Relational operators are used to compare both strings and/or
numerics.

## Syntax

```
exp relational.operator exp
```

## Description

Relational operators are:

`=`

`#`

`>=`

``>`

`These operators first attempt to convert both
operands into numerics. If successful, a numeric comparison is performed
at the current precision. If unable to convert *both* operands
into numerics, the operators convert both operands to strings and
perform a left-to-right comparison.

The value returned is nonzero
(true) or 0 (true).

Note: These strings are considered nonnumeric
only when used with the above relational operators: `"."`, `"+"`, `"-"`, `"-."`, `"+."`, and `""`.

## Example(s)

The result is `0`.

```
print 3 = 2
```
The result is nonzero because 2 was converted into a string
that comes before the string `"dog"` in alphabetical
order.

```
print 2 < "dog"
```
The result is nonzero (true). Although the first 3 characters
of `x` are actually a string of characters, the `=` operator was able to successfully convert this into a
number and do a numeric test for equality.

```
equ am to char(254)
x = "623abc"
print 623 = x[1,3]
```

## See also

- [! logical operator](https://d3codex.com/pickbasic-flashbasic/exclamation-logical-operator/)
- [* arithmetic operator](https://d3codex.com/pickbasic-flashbasic/asterisk-arithmetic-operator/)
- [* statement](https://d3codex.com/pickbasic-flashbasic/asterisk-statement/)
- [*= assignment operator](https://d3codex.com/pickbasic-flashbasic/asterisk-equals-assignment-operator/)
- [+ arithmetic operator](https://d3codex.com/pickbasic-flashbasic/plus-arithmetic-operator/)
- [+= assignment operator](https://d3codex.com/pickbasic-flashbasic/plus-equals-assignment-operator/)
- [, reserved character](https://d3codex.com/pickbasic-flashbasic/comma-reserved-character/)
- [- arithmetic operator](https://d3codex.com/pickbasic-flashbasic/minus-arithmetic-operator/)
- [-= assignment operator](https://d3codex.com/pickbasic-flashbasic/minus-equals-assignment-operator/)
- [/= assignment operator](https://d3codex.com/pickbasic-flashbasic/slash-equals-assignment-operator/)
- [= assignment operator](https://d3codex.com/pickbasic-flashbasic/equals-assignment-operator/)
- [> relational operator](https://d3codex.com/pickbasic-flashbasic/greater-than-relational-operator/)
- [Arithmetic expressions](https://d3codex.com/pickbasic-flashbasic/arithmetic-expressions/)
- [exp() function](https://d3codex.com/pickbasic-flashbasic/exp-function/)
- [le relational operator](https://d3codex.com/pickbasic-flashbasic/le-relational-operator/)
- [Logical expressions](https://d3codex.com/pickbasic-flashbasic/logical-expressions/)
- [loop statement](https://d3codex.com/pickbasic-flashbasic/loop-statement/)
- [lt relational operator](https://d3codex.com/pickbasic-flashbasic/lt-relational-operator/)
- [ne relational operator](https://d3codex.com/pickbasic-flashbasic/ne-relational-operator/)
- [Precedence](https://d3codex.com/pickbasic-flashbasic/precedence/)
- [precision statement](https://d3codex.com/pickbasic-flashbasic/precision-statement/)
- [Arrays and relational expressions](https://d3codex.com/pickbasic-flashbasic/arrays-and-relational-expressions/)
- [Reserved characters](https://d3codex.com/pickbasic-flashbasic/reserved-characters/)
- [\= assignment operator](https://d3codex.com/pickbasic-flashbasic/backslash-equals-assignment-operator/)
- [^ arithmetic operator](https://d3codex.com/pickbasic-flashbasic/caret-arithmetic-operator/)

---
Source: https://d3codex.com/pickbasic-flashbasic/relational-operators/ - part of the D3Codex reference.
