---
title: math.ldexp() function
description: math.ldexp() is the inverse of math.frexp(). It returns frac x 2**exp.
url: https://docs.influxdata.com/flux/v0/stdlib/math/ldexp/
estimated_tokens: 871
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/math/ldexp/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.22.0+

InfluxDB support

`math.ldexp()` is the inverse of `math.frexp()`. It returns `frac x 2**exp`.

##### Function type signature

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

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

## Parameters

### frac

(Required)
Fraction to use in the operation.

### exp

(Required)
Exponent to use in the operation.

## Examples

* [Return the inverse of math.frexp](#return-the-inverse-of-mathfrexp)
* [Use math.ldexp in map](#use-mathldexp-in-map)

### Return the inverse of math.frexp

```
import "math"

math.ldexp(frac: 0.5, exp: 6)// 32.0

```

### Use math.ldexp in map

```js
import "math"

data
    |> map(fn: (r) => ({_time: r._time, tag: r.tag, _value: math.ldexp(frac: r.frac, exp: r.exp)}))
```

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

View example input and output

#### Input data

|\*tag|       \_time       |exp|  frac   |
|-----|--------------------|---|---------|
| t1  |2021-01-01T00:00:00Z| 2 | \-0.545 |
| t1  |2021-01-01T00:00:10Z| 4 | 0.6825  |
| t1  |2021-01-01T00:00:20Z| 3 | 0.91875 |
| t1  |2021-01-01T00:00:30Z| 5 |0.5478125|
| t1  |2021-01-01T00:00:40Z| 4 |0.951875 |
| t1  |2021-01-01T00:00:50Z| 3 | 0.55375 |

|\*tag|       \_time       |exp|  frac   |
|-----|--------------------|---|---------|
| t2  |2021-01-01T00:00:00Z| 5 |0.6203125|
| t2  |2021-01-01T00:00:10Z| 3 | 0.62125 |
| t2  |2021-01-01T00:00:20Z| 2 |\-0.9375 |
| t2  |2021-01-01T00:00:30Z| 5 |0.6178125|
| t2  |2021-01-01T00:00:40Z| 4 | 0.86625 |
| t2  |2021-01-01T00:00:50Z| 1 |  0.93   |

#### Output data

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

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z| 19.85 | t2  |
|2021-01-01T00:00:10Z| 4.97  | t2  |
|2021-01-01T00:00:20Z|\-3.75 | t2  |
|2021-01-01T00:00:30Z| 19.77 | t2  |
|2021-01-01T00:00:40Z| 13.86 | t2  |
|2021-01-01T00:00:50Z| 1.86  | t2  |
| *tag | _time | exp | frac |
| --- | --- | --- | --- |
| *tag | _time | exp | frac |
| t1 | 2021-01-01T00:00:00Z | 2 | -0.545 |
| t1 | 2021-01-01T00:00:10Z | 4 | 0.6825 |
| t1 | 2021-01-01T00:00:20Z | 3 | 0.91875 |
| t1 | 2021-01-01T00:00:30Z | 5 | 0.5478125 |
| t1 | 2021-01-01T00:00:40Z | 4 | 0.951875 |
| t1 | 2021-01-01T00:00:50Z | 3 | 0.55375 |

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

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

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