BigQuery 中的 NUMERIC 和 FLOAT 有什么区别? [英] What is the difference between NUMERIC and FLOAT in BigQuery?
问题描述
我阅读了文档:
这不是错误 - 这正是
I read the docs: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types https://cloud.google.com/bigquery/pricing#data
I know that FLOAT
is 8 bytes while NUMERIC
is 16 bytes
Is that the only difference?
The docs says that NUMERIC
can range -99999999999999999999999999999.999999999
to 99999999999999999999999999999.999999999
but it doesn't specify the range for FLOAT
.
I like the current answers. I want to add this as a proof of why NUMERIC
is necessary:
SELECT
4.35 * 100 a_float
, CAST(4.35 AS NUMERIC) * 100 a_numeric
This is not a bug - this is exactly how the IEEE defines floats should be handled. Meanwhile NUMERIC
exhibits behavior closer to what humans expect.
For another proof of NUMERIC
usefulness, this answer shows how NUMERIC
can handle numbers too big for JavaScript to normally handle.
Before you blame BigQuery for this problem, you can check that most other programming languages will do the same. Python, for example:
这篇关于BigQuery 中的 NUMERIC 和 FLOAT 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!