Back to Influxdb

math.float64frombits() function

content/flux/v0/stdlib/math/float64frombits.md

latest3.2 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/math/math.flux#L882-L882 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

math.float64frombits() returns the floating-point number corresponding to the IEE 754 binary representation b, with the sign bit of b and the result in the same bit position.

Function type signature
js
(b: uint) => float

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

b

({{< req >}}) Value to operate on.

Examples

Convert bits into a float value

js
import "math"

math.float64frombits(b: uint(v: 4))// 2e-323


Use math.float64frombits in map

js
import "math"

data
    |> map(fn: (r) => ({r with _value: math.float64frombits(b: r._value)}))

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Z13835463379248627057t1
2021-01-01T00:00:10Z4622337031546119127t1
2021-01-01T00:00:20Z4619961382742681190t1
2021-01-01T00:00:30Z4625627474023866696t1
2021-01-01T00:00:40Z4624763345845364982t1
2021-01-01T00:00:50Z4616673755014700728t1
_time_value*tag
2021-01-01T00:00:00Z4626280495969835418t2
2021-01-01T00:00:10Z4617281740964395745t2
2021-01-01T00:00:20Z13838998704956112896t2
2021-01-01T00:00:30Z4626257977971698565t2
2021-01-01T00:00:40Z4623992104409177784t2
2021-01-01T00:00:50Z4611055514479556035t2

Output data

_time_value*tag
2021-01-01T00:00:00Z-2.18t1
2021-01-01T00:00:10Z10.92t1
2021-01-01T00:00:20Z7.35t1
2021-01-01T00:00:30Z17.53t1
2021-01-01T00:00:40Z15.23t1
2021-01-01T00:00:50Z4.43t1
_time_value*tag
2021-01-01T00:00:00Z19.85t2
2021-01-01T00:00:10Z4.97t2
2021-01-01T00:00:20Z-3.75t2
2021-01-01T00:00:30Z19.77t2
2021-01-01T00:00:40Z13.86t2
2021-01-01T00:00:50Z1.86t2

{{% /expand %}} {{< /expand-wrapper >}}