# Arithmetic operators

## Arithmetic operators

Numeric filters can be added, multiplied, and compared using standard arithmetic operators:gamenumber * movenumber + ply == 24The following are the allowed arithmetic operations on numeric filters:

operation | meaning |
---|---|

`+` | plus |

`-` | minus |

`-` | unary minus |

`*` | multiplication |

`/` | integer division |

`%` | modulus |

### matching the position

each such comparison or arithmetic operator is its own filter. For example, the CQL expressionpower A + power ais a

`+`

filter whose two arguments are `power A`

and `power a`

.
which can either match or not match the current position. Each such binary operator only matches the position if each of its two arguments also matches the position. (In addition, `/`

and `%`

will not match when their right hand arguments are zero).
For example, the following expression is equal to the number of white pieces in the previous position:

parent:#A

If the current position is the initial position, then the filter does not match. Thus,

0<1 + parent:#A

will match only if the current position is not the initial position.

# Examples

Arithmetic operators are used throughout the CQL examples. They are used extensively in averagedistance.cql, where we see computations like:sqrt(drank*drank + dfile*dfile)

This computes the square root (as an integer) of the sum of the squares of `drank`

and `dfile`

, which is used to compute the distance between two squares.