---
title: math.frexp() function
description: math.frexp() breaks f into a normalized fraction and an integral part of two.
url: https://docs.influxdata.com/flux/v0/stdlib/math/frexp/
estimated_tokens: 1770
product: Flux
version: v0
---

# math.frexp() function

-   Flux 0.22.0+
-   View InfluxDB support

`math.frexp()` breaks `f` into a normalized fraction and an integral part of two.

It returns **frac** and **exp** satisfying `f == frac x 2**exp`, with the absolute value of **frac** in the interval \[1/2, 1).

##### Function type signature

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

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

## Parameters

### f

(Required) Value to operate on.

## Examples

-   [Return the normalize fraction and integral of a value](#return-the-normalize-fraction-and-integral-of-a-value)
-   [Use math.frexp in map](#use-mathfrexp-in-map)

### Return the normalize fraction and integral of a value

```js
import "math"

math.frexp(f: 22.0)// {exp: 5, frac: 0.6875}

```

### Use math.frexp in map

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

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

            return {r with exp: result.exp, 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 | _value | exp | frac | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | -2.18 | 2 | -0.545 | t1 |
| 2021-01-01T00:00:10Z | 10.92 | 4 | 0.6825 | t1 |
| 2021-01-01T00:00:20Z | 7.35 | 3 | 0.91875 | t1 |
| 2021-01-01T00:00:30Z | 17.53 | 5 | 0.5478125 | t1 |
| 2021-01-01T00:00:40Z | 15.23 | 4 | 0.951875 | t1 |
| 2021-01-01T00:00:50Z | 4.43 | 3 | 0.55375 | t1 |

| _time | _value | exp | frac | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 19.85 | 5 | 0.6203125 | t2 |
| 2021-01-01T00:00:10Z | 4.97 | 3 | 0.62125 | t2 |
| 2021-01-01T00:00:20Z | -3.75 | 2 | -0.9375 | t2 |
| 2021-01-01T00:00:30Z | 19.77 | 5 | 0.6178125 | t2 |
| 2021-01-01T00:00:40Z | 13.86 | 4 | 0.86625 | t2 |
| 2021-01-01T00:00:50Z | 1.86 | 1 | 0.93 | t2 |
