UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Cheapest Paths
    • K-Hop Traversal
    • Graph Patterns
    • Overview
    • Open Graphs
    • Closed Graphs
    • Graphs with Edge ID
    • Graph Types
    • Constraints
    • Projections
    • Storage Maintenance
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • MERGE
    • SET
    • REMOVE
    • DELETE
    • FOREACH
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Execution Plan
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Naming Conventions
    • 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: 2.32

ceil()

Rounds a given number up to the nearest integer. 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

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

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: 3.142

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: 1.2

sqrt()

Computes the square root of a given number.

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

Result: 4

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: 7.38905609893065

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: 16

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: 4.605170185988092

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: 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: 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: 3.141592653589793

e()

Returns the mathematical constant e (Euler's number) approximately equal to 2.71828. e is the base of the natural logarithm.

Syntaxe()
Return TypeDOUBLE
GQL
RETURN e()

Result: 2.718281828459045

random()

Returns a random floating-point number between 0 (inclusive) and 1 (exclusive). rand() is an alias for random().

Syntaxrandom() or rand()
ArgumentsNone
Return TypeFLOAT
GQL
RETURN random()

Result: A random value such as 0.4094453725342517

sign()

Returns the sign of a number: -1 for negative, 0 for zero, 1 for positive.

Syntaxsign(<num>)
ArgumentsNameTypeDescription
<num>NumericThe target number
Return TypeINT
GQL
RETURN sign(-5), sign(0), sign(3.14)

Result:

sign(-5)sign(0)sign(3.14)
-101