ClickHouse/docs/ru/data_types/float.md
Ivan Blinkov 2e1f6bc56d
[experimental] add "es" docs language as machine translated draft (#9787)
* replace exit with assert in test_single_page

* improve save_raw_single_page docs option

* More grammar fixes

* "Built from" link in new tab

* fix mistype

* Example of include in docs

* add anchor to meeting form

* Draft of translation helper

* WIP on translation helper

* Replace some fa docs content with machine translation

* add normalize-en-markdown.sh

* normalize some en markdown

* normalize some en markdown

* admonition support

* normalize

* normalize

* normalize

* support wide tables

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* normalize

* lightly edited machine translation of introdpection.md

* lightly edited machhine translation of lazy.md

* WIP on translation utils

* Normalize ru docs

* Normalize other languages

* some fixes

* WIP on normalize/translate tools

* add requirements.txt

* [experimental] add es docs language as machine translated draft

* remove duplicate script

* Back to wider tab-stop (narrow renders not so well)
2020-03-21 07:11:51 +03:00

81 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Float32, Float64 {#float32-float64}
[Числа с плавающей запятой](https://en.wikipedia.org/wiki/IEEE_754).
Типы эквивалентны типам языка С:
- `Float32` - `float`;
- `Float64` - `double`.
Рекомендуется хранить данные в целочисленном виде всегда, когда это возможно. Например, переводите в целочисленные значения числа с фиксированной точностью, такие как денежные суммы или времена загрузки страниц в миллисекундах.
## Особенности использования чисел с плавающей запятой {#osobennosti-ispolzovaniia-chisel-s-plavaiushchei-zapiatoi}
- При вычислениях с числами с плавающей запятой возможна ошибка округления.
<!-- -->
``` sql
SELECT 1 - 0.9
```
``` text
┌───────minus(1, 0.9)─┐
│ 0.09999999999999998 │
└─────────────────────┘
```
- Результат вычисления зависит от метода вычисления (типа процессора и архитектуры вычислительной системы).
- При вычислениях с плавающей запятой возможно появление таких категорий числа как бесконечность (`Inf`) и «не число» (`NaN`). Это необходимо учитывать при обработке результатов вычислений.
- При чтении чисел с плавающей запятой из строк, в качестве результата может быть получено не обязательно ближайшее машинно-представимое число.
## NaN и Inf {#data-type-float-nan-inf}
В отличие от стандартного SQL, ClickHouse поддерживает следующие категории чисел с плавающей запятой:
- `Inf` - бесконечность.
<!-- -->
``` sql
SELECT 0.5 / 0
```
``` text
┌─divide(0.5, 0)─┐
│ inf │
└────────────────┘
```
- `-Inf` - отрицательная бесконечность;
<!-- -->
``` sql
SELECT -0.5 / 0
```
``` text
┌─divide(-0.5, 0)─┐
│ -inf │
└─────────────────┘
```
- `NaN` - не число.
<!-- -->
``` sql
SELECT 0 / 0
```
``` text
┌─divide(0, 0)─┐
│ nan │
└──────────────┘
```
Смотрите правила сортировки `NaN` в разделе [Секция ORDER BY](../query_language/select.md).
[Оригинальная статья](https://clickhouse.tech/docs/ru/data_types/float/) <!--hide-->