UltipaDocs
Try Playground
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Closed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Type Conversion Functions
    • Table Functions
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

Mathematical Functions

abs()

Returns the absolute value of a given number.

Syntaxabs(<num>)
ArgumentsNameTypeDescription
<num>NumericThe target number
Return TypeUINT
GQL
RETURN abs(-2.32)

Result:

abs(-2.32)
2.32

ceil()

Rounds a given number up to the nearest integer.

NOTE

ceiling() is a synonym to ceil().

Syntaxceil(<num>)
ArgumentsNameTypeDescription
<num>NumericThe target number
Return TypeINT
GQL
For item in [-2.92, 4.2]
RETURN ceil(item)

Result:

ceil(item)
-2
5

exp()

Computes the value of Euler's number 𝑒 raised to the power of a given number, where 𝑒 is approximately equal to 2.71828.

Syntaxexp(<num>)
ArgumentsNameTypeDescription
<num>NumericThe power to which 𝑒 is raised
Return TypeDOUBLE
GQL
RETURN exp(2)

Result:

exp(2)
7.38905609893065

floor()

Rounds a given number down to the nearest integer.

Syntaxfloor(<num>)
ArgumentsNameTypeDescription
<num>NumericThe target number
Return TypeINT
GQL
For item in [-2.92, 4.2]
RETURN floor(item)

Result:

floor(item)
-3
4

ln()

Computes the natural logarithm of a given number, i.e., the logarithm to the base 𝑒 (Euler's number, approximately 2.71828).

Syntaxln(<num>)
ArgumentsNameTypeDescription
<num>NumericA positive number to for which the logarithm is to be computed
Return TypeDOUBLE
GQL
RETURN ln(100)

Result:

ln(100)
4.60517018598809

log()

Computes the logarithm of a specified number with respect to a given base.

Syntaxlog(<base>, <num>)
ArgumentsNameTypeDescription
<base>NumericA postive number as the base of the logarithm
<num>NumericA positive number to for which the logarithm is to be computed
Return TypeDOUBLE
GQL
RETURN log(2, 8)

Result:

log(2, 8)
3

log10()

Computes the base 10 logarithm of a given number.

Syntaxlog10(<num>)
ArgumentsNameTypeDescription
<num>NumericA positive number to for which the logarithm is to be computed
Return TypeDOUBLE
GQL
RETURN log10(100)

Result:

log10(100)
2

mod()

Computes the modulus, or the remainder when one number is divided by another.

Syntaxmod(<dividend>, <divisor>)
ArgumentsNameTypeDescription
<dividend>NumericThe number to be divided
<divisor>NumericThe number by which the dividend is divided
Return TypeDOUBLE
GQL
RETURN mod(9.2, 2)

Result:

mod(9.2, 2)
1.2

pi()

Returns the mathematical constant π (pi) approximately equal to 3.14159. Pi is the ratio of a circle's circumference to its diameter in Euclidean geometry.

Syntaxpi()
Return TypeDOUBLE
GQL
RETURN pi()

Result:

pi()
3.14159265358979

power()

Raises a number to the power of another number.

Syntaxpower(<base>, <exponent>)
ArgumentsNameTypeDescription
<base>NumericThe number to be raised to a power
<exponent>NumericThe power to which the base is raised
Return TypeDOUBLE
GQL
RETURN power(2, 4)

Result:

power(2, 4)
16

round()

Returns the nearest value of a given number, rounded to a specified position of digits. If two nearest values are equidistant, it returns the one with the larger absolute value.

Syntaxround(<num>, [<digit>])
ArgumentsNameTypeDescription
<num>NumericThe target number to be rounded
<digit>INTThe position of digits to keep:
  • ...
  • -2 rounds to the hundreds place
  • -1 rounds to the tens place
  • 0 rounds to the nearest integer (default)
  • 1 rounds to one decimal place
  • 2 rounds to two decimal places
  • ...
Return TypeDOUBLE
GQL
RETURN round(3.1415926, 3)

Result:

round(3.1415926, 3)
3.142

sqrt()

Computes the square root of a given number.

Syntaxsqrt(<num>)
ArgumentsNameTypeDescription
<num>NumericThe target number
Return TypeDOUBLE
GQL
RETURN sqrt(16)

Result:

sqrt(16)
4