Metrics precision problem

Hi Matthias,

Druid internally represents metrics as float, but computes the results as double, since it is common for float aggregations to result in values that would be too large for a float to handle.

One could argue that if the result of a computation results in 25.09000015258789, that Druid should not return 25.09.

Our philosophy is that we should return the data as is, and leave it to the user to decide how to handle floating point values that cannot be represented exactly in binary format.

Hi Xavier,

thank you for your answer.

Based on the documentation and code i understand that metrics are represented as float, but results are computed as double.

So, there is no way for some arithmetics like sum over float values to convert them back to float in your client.



Indeed, we don’t currently have a way to cast results back to a different type. Users typically will do that as part of their client application along with any formatting requirements.