`ROUND()` function returns unexpected value

Viewed 119

I found in a specific case spanner's ROUND() function returns unexpected value.

Here's what I found.

SELECT ROUND(34.092135, 8)
> 34.092135

SELECT ROUND(34.092136, 8)
> 34.092135999999996 // this is supposed to return 34.092136

SELECT ROUND(34.092137, 8)
> 34.092137 

I found these queries work the same with BigQuery.
Is there any misassumption on my side, or if not, how can I make it work correctly?

Thanks.

1 Answers

The issue seems to be there for both Cloud Spanner and BigQuery. Tried with different values but the issue seems to be for a particular set of inputs i.e. it is showing the unexpected result for values 33.092136, 34.092136, 35.092136, ........., 62.092136, 63.092136. Before 33.092136 and from 64.092136 onwards the issue seems to be not there. Also I tried with Cloud SQL(MySQL) and the issue is not there.

I have created an issue in Public Issue Tracker for the same. I would suggest you star the issue so that you will get notified whenever there is any update on the created issue.

Related