Back to Influxdb

math.signbit() function

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

latest2.8 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#L1961-L1961 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

math.signbit() reports whether x is negative or negative zero.

Function type signature
js
(x: float) => bool

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

Parameters

x

({{< req >}}) Value to evaluate.

Examples

Test if a value is negative

js
import "math"

math.signbit(x: -1.2)// true


Use math.signbit in map

js
import "math"

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

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

Input data

_time*tag_value
2021-01-01T00:00:00Zt1-2.18
2021-01-01T00:00:10Zt1-0
2021-01-01T00:00:20Zt17.35
2021-01-01T00:00:30Zt1-0
2021-01-01T00:00:40Zt1-0
2021-01-01T00:00:50Zt14.43
_time*tag_value
2021-01-01T00:00:00Zt2-0
2021-01-01T00:00:10Zt24.97
2021-01-01T00:00:20Zt2-3.75
2021-01-01T00:00:30Zt219.77
2021-01-01T00:00:40Zt2-0
2021-01-01T00:00:50Zt21.86

Output data

_time_value*tag
2021-01-01T00:00:00Ztruet1
2021-01-01T00:00:10Ztruet1
2021-01-01T00:00:20Zfalset1
2021-01-01T00:00:30Ztruet1
2021-01-01T00:00:40Ztruet1
2021-01-01T00:00:50Zfalset1
_time_value*tag
2021-01-01T00:00:00Ztruet2
2021-01-01T00:00:10Zfalset2
2021-01-01T00:00:20Ztruet2
2021-01-01T00:00:30Zfalset2
2021-01-01T00:00:40Ztruet2
2021-01-01T00:00:50Zfalset2

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