Arithmetic Operators and Functions

The topics in this section describe the arithmetic operators and built-in SPARQL functions that operate on numeric (integer, decimal, float, and double) values.

Note: AnzoGraph automatically treats decimal values as doubles.

Operators

  • + for addition
  • - for subtraction
  • * for multiplication
  • / for division

To view example queries that incorporate arithmetic operators, see Arithmetic Operator Examples.

Functions

  • ABS: Returns the absolute value of the specified expression.
  • ADD: Returns the sum of the specified expressions.
  • BASE: Converts a number into the specified base and returns a text representation of the calculated value.
  • CEIL: Returns the ceiling value or next whole number up from the resulting value if the value has a fractional part.
  • COS: Calculates the cosine of the specified angle.
  • FLOOR: Returns the next whole number down from the resulting value if the value has a fractional part.
  • HAMMING_DIST: Calculates the hamming distance between two values.
  • HAVERSINE_DIST: Computes the haversine distance between two latitude and longitude values.
  • LN: Calculates the natural logarithm of numeric values.
  • LOG2: Returns the base two logarithm of a numeric value.
  • MOD: Returns the modulo or remainder of the division between two numeric values.
  • POWER: Raises a numeric value to the power of another numeric value.
  • RADIANS: Converts degrees into radians.
  • RAND: Returns a random double-precision number between 0 and 1, including 0 and excluding 1.
  • ROUND: Rounds the value up or down to the closest whole integer.
  • ROUNDDOWN: Rounds a numeric value down by the specified number of digits.
  • ROUNDUP: Rounds a numeric value up by the specified number of digits.
  • TAN: Calculates the tangent of the specified angle.
  • VAR: Calculates the variance for a group of numbers, i.e., how widely the values vary from the average of the values.
  • VARP: Calculates the variance for a sample group of numbers, i.e., how widely the values vary from the average of the values.