Loading TOC...

MarkLogic 12 Product Documentation
vec.trunc

vec.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 ]"

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.