# 18.2 Comparisons of Finite Field Elements

`z1 = z2`
`z1 < z2`

The equality operator `=` evaluates to `true` if the two elements in a finite field z1 and z2 are equal and to `false` otherwise. The inequality operator `<` evaluates to `true` if the two elements in a finite finite field z1 and z2 are not equal and to `false` otherwise.

Note that the integer 0 is not equal to the zero element in any finite field. There comparisons `z = 0` will always evaluate to `false`. Use `z = 0*z` instead, or even better `z = F.zero`, where F is the field record for a finite field of the same characteristic.

```    gap> Z(2^4)^10 = Z(2^4)^25;
true    # 'Z(2\^4)' has order 15
gap> Z(2^4)^10 = Z(2^2)^2;
true    # shows the embedding of 'GF(4)' into 'GF(16)'
gap> Z(2^4)^10 = Z(3);
false ```

`z1 < z2`
`z1 <= z2`
`z1 z2`
`z1 = z2`

The operators `<`, `<=`, , and `=` evaluate to `true` if the element in a finite field z1 is less than, less than or equal to, greater than, and greater than or equal to the element in a finite field z2.

Elements in finite fields are ordered as follows. If the two elements lie in fields of different characteristics the one that lies in the field with the smaller characteristic is smaller. If the two elements lie in different fields of the same characteristic the one that lies in the smaller field is smaller. If the two elements lie in the same field and one is the zero and the other is not, the zero element is smaller. If the two elements lie in the same field and both are nonzero, and are represented as Z(p^d)^{i_1} and Z(p^d)^{i_2} respectively, then the one with the smaller i is smaller.

You can compare elements in a finite field with objects of other types. Integers, rationals, and cyclotomics are smaller than elements in finite fields, all other objects are larger. Note especially that the integer 0 is smaller than the zero in every finite field.

```    gap> Z(2) < Z(3);
true
gap> Z(2) < Z(4);
true
gap> 0*Z(2) < Z(2);
true
gap> Z(4) < Z(4)^2;
true
gap> 0 < 0*Z(2);
true
gap> Z(4) < [ Z(4) ];
true ```

GAP 3.4.4
April 1997