Please enable JavaScript to view this site.

A-Shell Reference

Navigation: A-Shell BASIC (ASB) > Operators

Explicit Comparison Operators

Scroll Prev Top Next More

Added February 2019

Operator

Description

Operator

Description

#>

numeric greater than

$>

string greater than

#>=

numeric greater than or equal

$>=

string greater than or equal

#<

numeric less than

$<

string less than

#<=

numeric less than or equal

$<=

string less than or equal

#=

numeric equal

$=

string equal

##

numeric not equal

$#

string not equal

#<>

numeric not equal

$<>

string not equal

 

These are equivalent to the traditional comparison operators except that instead of the type of comparison being determined by the type of the leading value, here the type of comparison is established by the relative operator, which in turn may cause the leading comparator to be converted accordingly.

They are mainly useful when working with dynstruct members, which are treated by the compiler as strings, but which may be bound at runtime to numeric variables. If you know that you are working with a variable that should be treated as a number (or will be bound to a number), then using the explict-type comparisons will force the compiler to generate the comparison that you want, rather than the code that it thinks is appropriate.

For example:

if foo.price > foo.value then ...

if foo.price #> foo.value then ...

 

If foo is a dynstruct, then the compiler will treat foo.price and foo.value as strings, so it will interpret the first greater than operator as a string comparison. If foo.price and/or foo.value get re-bound to numeric variables at runtime, the string-type comparison will not yield the intended result. The second statement above resolves this by forcing the compiler to generate code for a numeric comparison.

Note that these operators are purely compiler constructs and do not require a corresponding update of the runtime system.

See Also

History

2019 February, A-Shell 6.5.1656, compiler edit 892:  Added to A-Shell.