Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

Math.trunc()

Truncate a number to a given precision.

Signature

Math.trunc(x: Number, precision: Number) => Number

Description

Gets the number x truncated to precision, depending on the underlying representation of the floating point number.

Parameters

Parameter Type Required Description

x

Number

Yes

A number.

precision

Number

Yes

Precision to truncate x to.

Return value

Type Description

Number

Value of x truncated to precision.

Examples

Math.trunc(12.123, 1)
12.1

 

Note that the result might reflect the underlying imprecision of the representation of a floating point number:

Math.trunc(12.123, 3)
12.122

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!