
MarkLogic 12 Product Documentation
vec.truncvec.trunc(
vector as vec.vector,
[n as Number?]
) as vec.vector
Summary
Returns a new vector which is a copy of the input vector with each element truncated to a specific number of digits.
| Parameters |
| vector |
The input vector to truncate.
|
| n |
The numbers of decimal places to truncate to. The default is 0. Negative values cause that many digits to the left of the decimal point to be truncated.
|
Example
const vec1 = vec.vector([1.234,2.654])
vec.trunc(vec1, 2)
=> "[ 1.23, 2.65 ]"
Copyright © 2026 MarkLogic Corporation. MARKLOGIC is a
registered trademark of MarkLogic Corporation.