0

When I insert the 667289685 value in a float32 field, ClickHouse round it to 667289660. Why does ClickHouse do that?

My example table

CREATE TABLE mytable (id Int32, valor Float32) 
ENGINE = MergeTree PRIMARY KEY (id)

Insert

INSERT INTO mytable values (1, 667289685)

Query

SELECT * FROM mytable

The result

id valor
1 667289660

I am using the HTTP API to insert the records.

Denny Crane
  • 11,574
  • 2
  • 19
  • 30
  • 2
    This is entirely expected, a 32-bit float has a precision of 6-7 decimal digits. 667289685 is "rounded" to 6.6728966E8 or 667289660. If you want a better precision, use a double precision (64-bit float), or an integer type. – Mark Rotteveel Dec 07 '22 at 12:22

0 Answers0