Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Insert float casted to double add noise to field #210

Copy link
Copy link
@Globostofo

Description

@Globostofo
Issue body actions

My goal is to insert my float variable in the database.
But when I call the addField method and cast the float into double, the variable gets a weird noise (little supplement) at the end:

This code:

float value = 3.141592f
influxdb::Point p1{"cpu"};
p1.addField("value", (double) value);
std::cout << p1.getFields() << std::endl;

displays this output:

value=3.141592025756835938

As you can see, a few digits are added at the end of the value, not far from the last digit.

I also tried casting with static_cast<double>(value) but it didn't work (same if I pass the float as is, without casting).

Edit:
To sum up, I'd like to know if it's possible to have as much precision as if I inserted a double:

value=3.141592000000000162

NB: with such a value, InfluxDB ignores the 162 at the end, and give me the tuple when I do a query with WHERE value=3.141592 (which is not the case with the float result).

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.