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

Returns a provided Number, truncated to a specified precision, depending on the underlying representation of the floating point number.

Parameters

Parameter Type Required Description

x

Number

true

A number.

precision

Number

true

Precision to truncate to.

Return value

Type Description

Number

The provided number, truncated to the specified 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!