math.modf() function

math.modf() returns integer and fractional floating-point numbers that sum to f.

Both values have the same sign as f.

Function type signature
(f: float) => {int: float, frac: float}
For more information, see Function type signatures.



(Required) Value to operate on.


Return the integer and float that sum to a value

import "math"

math.modf(f: 3.14)// {frac: 0.14000000000000012, int: 3}

Use math.modf in map

import "math"
import "sampledata"

    |> map(
        fn: (r) => {
            result = math.modf(f: r._value)

            return {_time: r._time, int:, frac: result.frac}

View example input and output

Was this page helpful?

Thank you for your feedback!

Linux Package Signing Key Rotation

All signed InfluxData Linux packages have been resigned with an updated key. If using Linux, you may need to update your package configuration to continue to download and verify InfluxData software packages.

For more information, see the Linux Package Signing Key Rotation blog post.