---
title: math.modf() function
description: math.modf() returns integer and fractional floating-point numbers that sum to f.
url: https://docs.influxdata.com/flux/v0/stdlib/math/modf/
estimated_tokens: 1682
product: Flux
version: v0
---

# math.modf() function

-   Flux 0.22.0+
-   View InfluxDB support

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

Both values have the same sign as `f`.

##### Function type signature

```js
(f: float) => {int: float, frac: float}
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### f

(Required) Value to operate on.

## Examples

-   [Return the integer and float that sum to a value](#return-the-integer-and-float-that-sum-to-a-value)
-   [Use math.modf in map](#use-mathmodf-in-map)

### Return the integer and float that sum to a value

```js
import "math"

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

```

### Use math.modf in map

```js
import "math"
import "sampledata"

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

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

[](#view-example-input-and-output)

View example input and output

#### Input data

| _time | *tag | _value |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | t1 | -2.18 |
| 2021-01-01T00:00:10Z | t1 | 10.92 |
| 2021-01-01T00:00:20Z | t1 | 7.35 |
| 2021-01-01T00:00:30Z | t1 | 17.53 |
| 2021-01-01T00:00:40Z | t1 | 15.23 |
| 2021-01-01T00:00:50Z | t1 | 4.43 |

| _time | *tag | _value |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | t2 | 19.85 |
| 2021-01-01T00:00:10Z | t2 | 4.97 |
| 2021-01-01T00:00:20Z | t2 | -3.75 |
| 2021-01-01T00:00:30Z | t2 | 19.77 |
| 2021-01-01T00:00:40Z | t2 | 13.86 |
| 2021-01-01T00:00:50Z | t2 | 1.86 |

#### Output data

| _time | frac | int |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -0.18000000000000016 | -2 |
| 2021-01-01T00:00:10Z | 0.9199999999999999 | 10 |
| 2021-01-01T00:00:20Z | 0.34999999999999964 | 7 |
| 2021-01-01T00:00:30Z | 0.5300000000000011 | 17 |
| 2021-01-01T00:00:40Z | 0.23000000000000043 | 15 |
| 2021-01-01T00:00:50Z | 0.4299999999999997 | 4 |
| 2021-01-01T00:00:00Z | 0.8500000000000014 | 19 |
| 2021-01-01T00:00:10Z | 0.9699999999999998 | 4 |
| 2021-01-01T00:00:20Z | -0.75 | -3 |
| 2021-01-01T00:00:30Z | 0.7699999999999996 | 19 |
| 2021-01-01T00:00:40Z | 0.8599999999999994 | 13 |
| 2021-01-01T00:00:50Z | 0.8600000000000001 | 1 |
