mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-20 23:41:01 +00:00
8623cb232c
* CLICKHOUSE-4063: less manual html @ index.md * CLICKHOUSE-4063: recommend markdown="1" in README.md * CLICKHOUSE-4003: manually purge custom.css for now * CLICKHOUSE-4064: expand <details> before any print (including to pdf) * CLICKHOUSE-3927: rearrange interfaces/formats.md a bit * CLICKHOUSE-3306: add few http headers * Remove copy-paste introduced in #3392 * Hopefully better chinese fonts #3392 * get rid of tabs @ custom.css * Apply comments and patch from #3384 * Add jdbc.md to ToC and some translation, though it still looks badly incomplete * minor punctuation * Add some backlinks to official website from mirrors that just blindly take markdown sources * Do not make fonts extra light * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's//g' {} * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's/ sql/g' {} * Remove outdated stuff from roadmap.md * Not so light font on front page too * Refactor Chinese formats.md to match recent changes in other languages
1.9 KiB
1.9 KiB
Float32, Float64
Types are equivalent to types of C:
Float32
-float
Float64
-double
We recommend that you store data in integer form whenever possible. For example, convert fixed precision numbers to integer values, such as monetary amounts or page load times in milliseconds.
Using Floating-point Numbers
- Computations with floating-point numbers might produce a rounding error.
SELECT 1 - 0.9
┌───────minus(1, 0.9)─┐
│ 0.09999999999999998 │
└─────────────────────┘
- The result of the calculation depends on the calculation method (the processor type and architecture of the computer system).
- Floating-point calculations might result in numbers such as infinity (
Inf
) and "not-a-number" (NaN
). This should be taken into account when processing the results of calculations. - When reading floating point numbers from rows, the result might not be the nearest machine-representable number.
NaN and Inf
In contrast to standard SQL, ClickHouse supports the following categories of floating-point numbers:
Inf
– Infinity.
SELECT 0.5 / 0
┌─divide(0.5, 0)─┐
│ inf │
└────────────────┘
-Inf
– Negative infinity.
SELECT -0.5 / 0
┌─divide(-0.5, 0)─┐
│ -inf │
└─────────────────┘
NaN
– Not a number.
SELECT 0 / 0
┌─divide(0, 0)─┐
│ nan │
└──────────────┘
See the rules for NaN
sorting in the section ORDER BY clause.