Converts `value` to [Decimal](../../data_types/decimal.md) of precision `S`. The `value` can be a number or a string. The `S` (scale) parameter specifies the number of decimal places.
## toDecimal(32|64|128)OrNull
Converts an input string to the value of [Nullable(Decimal(P,S))](../../data_types/decimal.md) data type. This family of functions include:
-`toDecimal32OrNull(expr, S)` — Results with `Nullable(Decimal32(S))` data type.
-`toDecimal64OrNull(expr, S)` — Results with `Nullable(Decimal64(S))` data type.
-`toDecimal128OrNull(expr, S)` — Results with `Nullable(Decimal128(S))` data type.
These functions should be used instead of `toDecimal*()` functions, if you prefer to get the `NULL` value instead of exception, when input value parsing error.
**Parameters**
-`expr` — [Expression](../syntax.md#syntax-expressions), returning a value of the [String](../../data_types/string.md) data type. ClickHouse expects the textual representation of the decimal number. For example, "1.111".
-`S` — Scale, the number of decimal places in the resulting value.
**Returned value**
The value of `Nullable(Decimal(P,S))` data type. `P` equals to numeric part of the function name. For example, for the `toDecimal32OrNull` function `P = 32`. The value contains:
- Number with `S` decimal places, if ClickHouse could interpret input string as a number.
-`NULL`, if ClickHouse couldn't interpret input string as a number or if the input number contains more decimal places then `S`.
Converts an input value to the [Decimal(P,S)](../../data_types/decimal.md) data type. This family of functions include:
-`toDecimal32OrZero( expr, S)` — Results with `Decimal32(S)` data type.
-`toDecimal64OrZero( expr, S)` — Results with `Decimal64(S)` data type.
-`toDecimal128OrZero( expr, S)` — Results with `Decimal128(S)` data type.
These functions should be used instead of `toDecimal*()` functions, if you prefer to get the `0` value instead of exception, when input value parsing error.
**Parameters**
-`expr` — [Expression](../syntax.md#syntax-expressions), returning a value of the [String](../../data_types/string.md) data type. ClickHouse expects the textual representation of the decimal number. For example, `'1.111'`.
-`S` — Scale, the number of decimal places in the resulting value.
**Returned value**
The value of `Nullable(Decimal(P,S))` data type. `P` equals to numeric part of the function name. For example, for the `toDecimal32OrZero` function `P = 32`. The value contains:
- Number with `S` decimal places, if ClickHouse could interpret input string as a number.
- 0 with `S` decimal places, if ClickHouse couldn't interpret input string as a number or if the input number contains more decimal places then `S`.