Arithmetic Operators

This reference covers CQL specification version 3.3.1

CQL supports the following operators:

Operator Description
- (unary) Negates operand
+ Addition
- Substraction
* Multiplication
/ Division
% Returns the remainder of a division

Number Arithmetic

All arithmetic operations are supported on numeric types or counters.

The return type of the operation will be based on the operand types:

left/right tinyint smallint int bigint counter float double varint decimal
tinyint tinyint smallint int bigint bigint float double varint decimal
smallint smallint smallint int bigint bigint float double varint decimal
int int int int bigint bigint float double varint decimal
bigint bigint bigint bigint bigint bigint double double varint decimal
counter bigint bigint bigint bigint bigint double double varint decimal
float float float float double double float double decimal decimal
double double double double double double double double decimal decimal
varint varint varint varint decimal decimal decimal decimal decimal decimal
decimal decimal decimal decimal decimal decimal decimal decimal decimal decimal

*, / and % operators have a higher precedence level than + and - operator. By consequence, they will be evaluated before. If two operator in an expression have the same precedence level, they will be evaluated left to right based on their position in the expression.

© 2016, The Apache Software Foundation.

Apache Cassandra Query Language