DECFLOAT
DECFLOAT is a floating-point data type in SQL that's used to store high precision decimal numbers. Depending on the specified precision, two types can be used: DECFLOAT(16), which stores approximately 16 decimal digits of precision, or DECFLOAT(34), which stores approximately 34 decimal digits of precision. Offering a broader range and greater precision than other numeric types, DECFLOAT is best suited for complex mathematics or scientific calculations.
Example
Output
Explanation
In the SQL code example, a DECFLOAT variable ‘@myDecfloat’ is declared and assigned the value “10.567”. Then, a SELECT statement is used to view the value of ‘@myDecfloat’. The output shows the stored value “10.567”.
Example
Output
Explanation
In the example, a variable, @MyVar
, of DECFLOAT
data type with a precision of 34 is declared. The @MyVar
variable is then set to the numerical value 1234567890.123456
. The SELECT
statement is subsequently used to display the set value of the @MyVar
variable. The DECFLOAT
data type holds large decimal numbers with high precision, it can hold up to 34 digits to the left and right of the decimal point.