Returns the absolute value of a given number.
| Syntax | abs(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number | |
| Return Type | UINT | ||
GQLRETURN abs(-2.32)
Result: 2.32
Rounds a given number up to the nearest integer. ceiling() is a synonym to ceil()
| Syntax | ceil(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number | |
| Return Type | INT | ||
GQLFor item in [-2.92, 4.2] RETURN ceil(item)
Result:
| ceil(item) |
|---|
| -2 |
| 5 |
Rounds a given number down to the nearest integer.
| Syntax | floor(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number | |
| Return Type | INT | ||
GQLFor item in [-2.92, 4.2] RETURN floor(item)
Result:
| floor(item) |
|---|
| -3 |
| 4 |
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.
| Syntax | round(<num>, [<digit>]) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number to be rounded | |
<digit> | INT | The position of digits to keep:
| |
| Return Type | DOUBLE | ||
GQLRETURN round(3.1415926, 3)
Result: 3.142
Computes the modulus, or the remainder when one number is divided by another.
| Syntax | mod(<dividend>, <divisor>) | ||
| Arguments | Name | Type | Description |
<dividend> | Numeric | The number to be divided | |
<divisor> | Numeric | The number by which the dividend is divided | |
| Return Type | DOUBLE | ||
GQLRETURN mod(9.2, 2)
Result: 1.2
Computes the square root of a given number.
| Syntax | sqrt(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number | |
| Return Type | DOUBLE | ||
GQLRETURN sqrt(16)
Result: 4
Computes the value of Euler's number 𝑒 raised to the power of a given number, where 𝑒 is approximately equal to 2.71828.
| Syntax | exp(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The power to which 𝑒 is raised | |
| Return Type | DOUBLE | ||
GQLRETURN exp(2)
Result: 7.38905609893065
Raises a number to the power of another number.
| Syntax | power(<base>, <exponent>) | ||
| Arguments | Name | Type | Description |
<base> | Numeric | The number to be raised to a power | |
<exponent> | Numeric | The power to which the base is raised | |
| Return Type | DOUBLE | ||
GQLRETURN power(2, 4)
Result: 16
Computes the natural logarithm of a given number, i.e., the logarithm to the base 𝑒 (Euler's number, approximately 2.71828).
| Syntax | ln(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | A positive number to for which the logarithm is to be computed | |
| Return Type | DOUBLE | ||
GQLRETURN ln(100)
Result: 4.605170185988092
Computes the logarithm of a specified number with respect to a given base.
| Syntax | log(<base>, <num>) | ||
| Arguments | Name | Type | Description |
<base> | Numeric | A postive number as the base of the logarithm | |
<num> | Numeric | A positive number to for which the logarithm is to be computed | |
| Return Type | DOUBLE | ||
GQLRETURN log(2, 8)
Result: 3
Computes the base 10 logarithm of a given number.
| Syntax | log10(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | A positive number to for which the logarithm is to be computed | |
| Return Type | DOUBLE | ||
GQLRETURN log10(100)
Result: 2
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.
| Syntax | pi() |
| Return Type | DOUBLE |
GQLRETURN pi()
Result: 3.141592653589793
Returns a random floating-point number between 0 (inclusive) and 1 (exclusive). rand() is an alias for random().
| Syntax | random() or rand() | ||
| Arguments | None | ||
| Return Type | FLOAT | ||
GQLRETURN random()
Result: A random value such as 0.4094453725342517
Returns the sign of a number: -1 for negative, 0 for zero, 1 for positive.
| Syntax | sign(<num>) | ||
| Arguments | Name | Type | Description |
<num> | Numeric | The target number | |
| Return Type | INT | ||
GQLRETURN sign(-5), sign(0), sign(3.14)
Result:
| sign(-5) | sign(0) | sign(3.14) |
|---|---|---|
| -1 | 0 | 1 |