2018-09-06 10:22:06 +00:00
< div dir = "rtl" markdown = "1" >
2018-08-12 03:03:37 +00:00
# Float32, Float64
[اعداد Float ](https://en.wikipedia.org/wiki/IEEE_754 ).
Type های float در ClickHouse مشابه C می باشد:
- `Float32` - `float`
2018-12-25 15:25:43 +00:00
- `Float64` - `double`
2018-08-12 03:03:37 +00:00
توصیه می کنیم که داده ه ا را هرزمان که امکان پذیره است به جای float به صورت int ذخیره کنید. برای مثال: تبدیل دقت اعداد به یک مقدار int، مثل سرعت page load در قالب میلی ثانیه.
## استفاده از اعداد Float
- محاسبات با اعداد با Float ممکن است خطای round شدن را ایجاد کنند.
< / div >
2018-10-16 10:47:17 +00:00
``` sql
2018-08-12 03:03:37 +00:00
SELECT 1 - 0.9
```
```
┌───────minus(1, 0.9)─┐
│ 0.09999999999999998 │
└─────────────────────┘
```
2018-09-06 10:22:06 +00:00
< div dir = "rtl" markdown = "1" >
2018-08-12 03:03:37 +00:00
- نتایج محاسبات بسته به متد محاسباتی می باشد (نوع processor و معماری سیستم).
- محاسبات Float ممکن اسن نتایجی مثل infinity (`inf`) و "Not-a-number" (`Nan`) داشته باشد. این در هنگام پردازش نتایج محاسبات باید مورد توجه قرار گیرد.
- هنگام خواندن اعداد float از سطر ها، نتایج ممکن است نزدیک به اعداد machine-representable نباشد.
## NaN و Inf
در مقابل استاندارد SQL، ClickHouse از موارد زیر مربوط به اعداد float پشتیبانی می کند:
- `Inf` – Infinity.
< / div >
2018-10-16 10:47:17 +00:00
``` sql
2018-08-12 03:03:37 +00:00
SELECT 0.5 / 0
```
```
┌─divide(0.5, 0)─┐
│ inf │
└────────────────┘
```
2018-09-06 10:22:06 +00:00
< div dir = "rtl" markdown = "1" >
2018-08-12 03:03:37 +00:00
- `-Inf` – Negative infinity.
< / div >
2018-10-16 10:47:17 +00:00
``` sql
2018-08-12 03:03:37 +00:00
SELECT -0.5 / 0
```
```
┌─divide(-0.5, 0)─┐
│ -inf │
└─────────────────┘
```
2018-09-06 10:22:06 +00:00
< div dir = "rtl" markdown = "1" >
2018-08-12 03:03:37 +00:00
- `NaN` – Not a number.
< / div >
```
SELECT 0 / 0
```
```
┌─divide(0, 0)─┐
│ nan │
└──────────────┘
```
2018-09-06 10:22:06 +00:00
< div dir = "rtl" markdown = "1" >
2018-08-12 03:03:37 +00:00
2018-12-12 17:28:00 +00:00
قوانین مربوط به مرتب سازی ` Nan ` را در بخش [ORDER BY clause ](../query_language/select.md ) ببینید.
2018-08-12 03:03:37 +00:00
2018-10-16 10:47:17 +00:00
< / div >
[مقاله اصلی ](https://clickhouse.yandex/docs/fa/data_types/float/ ) <!--hide-->