2017-12-28 15:13:23 +00:00
# Float32, Float64
[Floating point numbers ](https://en.wikipedia.org/wiki/IEEE_754 ).
Types are equivalent to types of C:
2018-03-25 02:04:22 +00:00
- `Float32` - `float`
2018-12-25 15:25:43 +00:00
- `Float64` - `double`
2017-12-28 15:13:23 +00:00
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.
2018-08-10 14:44:49 +00:00
## Using Floating-point Numbers
2017-12-28 15:13:23 +00:00
- Computations with floating-point numbers might produce a rounding error.
2018-10-16 10:47:17 +00:00
``` sql
2017-12-29 12:43:05 +00:00
SELECT 1 - 0.9
```
2018-09-04 11:18:59 +00:00
2017-12-29 12:43:05 +00:00
```
┌───────minus(1, 0.9)─┐
│ 0.09999999999999998 │
└─────────────────────┘
```
2017-12-28 15:13:23 +00:00
- 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.
2019-03-27 21:31:08 +00:00
- When parsing floating point numbers from text, the result might not be the nearest machine-representable number.
2017-12-28 15:13:23 +00:00
2019-08-21 07:52:51 +00:00
## NaN and Inf {#data_type-float-nan-inf}
2017-12-28 15:13:23 +00:00
In contrast to standard SQL, ClickHouse supports the following categories of floating-point numbers:
- `Inf` – Infinity.
2018-10-16 10:47:17 +00:00
``` sql
2017-12-29 12:43:05 +00:00
SELECT 0.5 / 0
```
2017-12-28 15:13:23 +00:00
2017-12-29 12:43:05 +00:00
```
┌─divide(0.5, 0)─┐
│ inf │
└────────────────┘
```
2018-03-25 02:04:22 +00:00
2017-12-28 15:13:23 +00:00
- `-Inf` – Negative infinity.
2018-10-16 10:47:17 +00:00
``` sql
2017-12-29 12:43:05 +00:00
SELECT -0.5 / 0
```
2017-12-28 15:13:23 +00:00
2017-12-29 12:43:05 +00:00
```
┌─divide(-0.5, 0)─┐
│ -inf │
└─────────────────┘
```
2018-03-25 02:04:22 +00:00
2017-12-28 15:13:23 +00:00
- `NaN` – Not a number.
2017-12-29 12:43:05 +00:00
```
SELECT 0 / 0
```
2017-12-28 15:13:23 +00:00
2017-12-29 12:43:05 +00:00
```
┌─divide(0, 0)─┐
│ nan │
└──────────────┘
```
2017-12-28 15:13:23 +00:00
2018-12-12 17:28:00 +00:00
See the rules for `NaN` sorting in the section [ORDER BY clause ](../query_language/select.md ).
2017-12-28 15:13:23 +00:00
2018-10-16 10:47:17 +00:00
[Original article ](https://clickhouse.yandex/docs/en/data_types/float/ ) <!--hide-->