TOC < Back Next > Updated: 6-Feb-2009 Edit History

# REBOL 3 Concepts: Math: Comparison Functions

Pending Revision

This document was written for R2 and has yet to be revised for R3.

All comparison functions return either true or false.

## equal

The expressions:

```value1 = value2

equal? value1 value2```

return true if the first and second values are equal.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes.

```print 11-11-99 = 11-11-99
true```
```print equal? 111.112.111.111 111.112.111.111
true```
```print #"B" = #"B"
true```
```print equal? "a b c d" "A B C D"
true```

## greater

The expressions:

```value1 > value2

greater? value1 value2```

return true if the first value is greater than the second value.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes.

```print 13-11-99 > 12-11-99
true```
```print greater? 113.111.111.111 111.112.111.111
true```
```print #"C" > #"B"
true```
```print greater? [12 23 34] [12 23 33]
true```

## greater-or-equal

The expressions:

```value1 >= value2

greater-or-equal? value1 value2```

return true if the first value is greater than or equal to the second value.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes.

```print 11-12-99 >= 11-11-99
true```
```print greater-or-equal? 111.112.111.111 111.111.111.111
true```
```print #"B" >= #"A"
true```
```print greater-or-equal? [b c d e] [a b c d]
true```

## lesser

The expressions:

```value1 < value2

lesser? value1 value2```

return true if the first value is less than second value.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes:

```print 25 < 50
true```
```print lesser? 25.3 25.5
true```
```print \$2.00 < \$2.30
true```
```print lesser? 00:10:11 00:11:11
true```

## lesser-or-equal

The expressions:

```value1 <= value2

lesser-or-equal? value1 value2```

return true if the first value is less than or equal to the second value.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes.

```print 25 <= 25
true```
```print lesser-or-equal? 25.3 25.5
true```
```print \$2.29 <= \$2.30
true```
```print lesser-or-equal? 11:11:10 11:11:11
true```

## not equal to

The expressions:

```value1 <> value2

not-equal? value1 value2```

return true if the first and second values are not equal.

Works with integer!, decimal!, money!, time!, date!, tuple!, char! and [bad-link:datatypes/series.txt] datatypes.

```print 26 <> 25
true```
```print not-equal? 25.3 25.5
true```
```print \$2.29 <> \$2.30
true```
```print not-equal? 11:11:10 11:11:11
true```

## same

The expressions:

```value1 =? value2

same? value1 value2```

return true if two words refer to the same value. For instance, when you want to see if two words are referencing the same index in a series.

Work with all datatypes.

```reference-one: "abcdef"
reference-two: reference-one
print same? reference-one reference-two
true```
```reference-one: next reference-one
print same? reference-one reference-two
false```
```reference-two: next reference-two
print same? reference-one reference-two
true```
```reference-two: copy reference-one
print same? reference-one reference-two
false```

## strict-equal

The expressions:

```value1 == value2

strict-equal? value1 value2```

return true if the first and second values are strictly the same. Can be used as a case-sensitive version of the equal? (' = ) operator for strings and to differentiate between integers and decimals when their values are the same.

Works with all datatypes.

```print strict-equal? "abc" "ABC"
false```
```print equal? "abc" "ABC"
true```
```print strict-equal? "abc" "abc"
true```
```print strict-equal? 1 1.0
false```
```print equal? 1 1.0
true```
```print strict-equal? 1.0 1.0
true```

## strict-not-equal

The expression:

`strict-not-equal? value1 value2`

returns true if the first and second values are strictly not the same. Can be used as a case-sensitive version of the not-equal? (' <> ) operator for strings and to differentiate between integers and decimals when their values are the same.

Works with all datatypes.

```print strict-not-equal? "abc" "ABC"
true```
```print not-equal? "abc" "ABC"
false```
```print strict-not-equal? "abc" "abc"
false```
```print strict-not-equal? 1 1.0
true```
```print not-equal? 1 1.0
false```
```print strict-not-equal? 1.0 1.0
false```

 TOC < Back Next > Feedback Admin