Documentation

Work with floats

A float type represents a IEEE-754 64-bit floating-point number.

Type name: float

Float syntax

A float literal contains a decimal integer, a decimal point, and a decimal fraction.

0.0
123.4
-123.456

Scientific notation

Flux does not support scientific notation float literal syntax. However, you can use float() to convert a scientific notation string into a float type.

1.23456e+78
// Error: error @1:8-1:9: undefined identifier e

float(v: "1.23456e+78")
// Returns 1.23456e+78 (float)

Infinity

Flux does not support infinite float literal syntax (+Inf and -Inf). However, you can use float() to convert a infinite string into a float type.

+Inf
// Error: error @1:2-1:5: undefined identifier Inf

float(v: "+Inf")
// Returns +Inf (float)

Not a Number

Flux does not support Not a Number (NaN) float literal syntax. However, you can use float() to convert a NaN string into a float type.

NaN
// Error: error @1:2-1:5: undefined identifier NaN

float(v: "NaN")
// Returns NaN (float)

Convert data types to floats

Use the float() function to convert the following basic types to floats:

  • string: must be a numeric string or scientific notation
  • bool: true converts to 1.0, false converts to 0.0
  • int
  • uint
float(v: "1.23")
// 1.23

float(v: true)
// Returns 1.0

float(v: 123)
// Returns 123.0

Convert columns to floats

Flux lets you iterate over rows in a stream of tables and convert columns to floats.

To convert the _value column to floats, use the toFloat() function.

toFloat() only operates on the _value column.

data
    |> toFloat()
Given the following input data:
_time_value (int)
2021-01-01T00:00:00Z10
2021-01-01T02:00:00Z20
2021-01-01T03:00:00Z30
2021-01-01T04:00:00Z40
The example above returns:
_time_value (float)
2021-01-01T00:00:00Z10.0
2021-01-01T02:00:00Z20.0
2021-01-01T03:00:00Z30.0
2021-01-01T04:00:00Z40.0

To convert any column to floats:

  1. Use map() to iterate over and rewrite rows.
  2. Use float() to convert columns values to floats.
data
    |> map(fn: (r) => ({ r with index: float(v: r.index) }))
Given the following input data:
_timeindex (int)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z2
2021-01-01T03:00:00Z3
2021-01-01T04:00:00Z4
The example above returns:
_timeindex (float)
2021-01-01T00:00:00Z1.0
2021-01-01T02:00:00Z2.0
2021-01-01T03:00:00Z3.0
2021-01-01T04:00:00Z4.0

Operate on floats

Perform arithmetic operations on floats

To perform operations like adding, subtracting, multiplying, or dividing float values, use Flux arithmetic operators. Operands must be the same type.

1.23 + 45.67
// Returns 46.9

1.23 - 45.67
// Returns -44.440000000000005

float(v: "12345e+67") * 100.0
// Returns 1.2345000000000001e+73

144.0 / 12.0
// Returns 12.0

10.0 ^ 2.0
// Returns 100.0

Inherent rounding errors in floating-point arithmetic

To fit an infinite number of real values into a finite number of bits, computer systems must round floating-point values in arithmetic operations. This results in small rounding errors in some operations.

Compare float values

Use Flux comparison operators to compare float values. Operands must be the same type. The operation returns a float.

12345600.0 == float(v: "1.23456e+07")
// Returns true

1.2 > -2.1
// Returns true

Round float values

  1. Import the math package.
  2. Use math.round() to round to the nearest whole number.
import "math"

math.round(x: 1.54)
// Returns 2.0

Flux math package

Use the math package to perform operations on float values.


Was this page helpful?

Thank you for your feedback!


InfluxDB OSS 2.9.0: API tokens are hashed by default

Stronger token security in InfluxDB OSS 2.9.0 — tokens are hashed on disk by default. Existing tokens are hashed on first startup and can’t be recovered afterward. Capture any plaintext tokens you still need before you upgrade.

View InfluxDB OSS 2.9.0 release notes

Hashed tokens authenticate exactly like unhashed tokens — clients and integrations keep working.

Also new in 2.9.0:

  • Configurable backup compression
  • Restore support for backups containing hashed tokens
  • Tighter Edge Data Replication queue validation
  • Flux upgrade
  • Compaction reliability improvements

Key enhancements in Explorer 1.8

Explorer 1.8 is now available with streaming data subscriptions (beta), line protocol preview, and query history & saved queries.

View Explorer 1.8 release notes

Explorer 1.8 includes new features and improvements that make it easier to ingest, explore, and manage data.

Highlights:

  • Streaming data subscriptions (beta): Stream data into Explorer from MQTT, Kafka, and AMQP sources.
  • Line protocol preview: Preview line protocol, schema, and parse errors before data is written.
  • Custom sample data: Generate custom sample datasets with line protocol and schema preview.
  • Query history and saved queries: Browse query history and save/re-run named queries.
  • Retention period management: Set, update, or clear retention periods on databases and tables.

For more details, see Explorer 1.8 release notes

InfluxDB 3.9: Performance upgrade preview

InfluxDB 3 Enterprise 3.9 includes a beta of major performance upgrades with faster single-series queries, wide-and-sparse table support, and more.

InfluxDB 3 Enterprise 3.9 includes a beta of major performance and feature updates.

Key improvements:

  • Faster single-series queries
  • Consistent resource usage
  • Wide-and-sparse table support
  • Automatic distinct value caches for reduced latency with metadata queries

Preview features are subject to breaking changes.

For more information, see:

Telegraf Enterprise now in public beta

Get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

See the Blog Post

The upcoming Telegraf Enterprise offering is for organizations running Telegraf at scale and is comprised of two key components:

  • Telegraf Controller: A control plane (UI + API) that centralizes Telegraf configuration management and agent health visibility.
  • Telegraf Enterprise Support: Official support for Telegraf Controller and Telegraf plugins.

Join the Telegraf Enterprise beta to get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

For more information:

Telegraf Controller v0.0.7-beta now available

Telegraf Controller v0.0.7-beta is now available with new features, improvements, bug fixes, and an important breaking change.

View the release notes
Download Telegraf Controller v0.0.7-beta

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On May 27, 2026, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2