|
Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - Differences between DECIMAL and FLOAT
By: FYIcenter.com
(Continued from previous topic...)
What Are the Differences between DECIMAL and FLOAT?
DECIMAL and FLOAT are both used to store numerical values.
But they have the following main differences:
- DECIMAL(p,s) stores values with the decimal point fixed at the position of s (scale) digits from the right.
The total number of decimal digits is also fixed as p (precesion).
- FLOAT(n) stores values with the decimal point floating based on the value. The number of bits used
to store the mantissa part is fixed as n.
- If the input value of DECIMAL(p,s) has more digits after the decimal point than the scale s,
the value will be rounded to the scale s.
- If the input value of FLOAT(n) has more total digits (mantissa) than what n bits can store,
the value will be rounded to fit the storage size.
- If the input value of DECIMAL(p,s) has more digits before the decimal point than p-s,
SQL Server will give you an over-flow error.
- If the input value of FLOAT(n) is too big that the exponential part goes over the positive limit,
SQL Server will give you an over-flow error.
- If the input value of FLOAT(n) is too small that the exponential part goes over the negative limit,
SQL Server will give you an under-flow error.
- What Is SQL Language?
- What Is Transact-SQL Language?
- What Is a Transact-SQL Statement?
- How To Start and End Transact-SQL Statements?
- How To Enter Comments in Transact-SQL Statements?
- What Is a Transact-SQL Statement Batch?
- What Happens to a Statement Batch If There Is a Compilation Error?
- How To Use GO Command in "sqlcmd"?
- How To Create User Messages with PRINT Statements?
- How Many Categories of Data Types Used by SQL Server?
- What Are Exact Numeric Data Types?
- What Are Approximate Numeric Data Types?
- What Are Date and Time Data Types?
- What Are Character String Data Types?
- What Are Unicode Character String Data Types?
- What Are Binary String Data Types?
- What Are the Differences between CHAR and NCHAR?
- What Are the Differences between CHAR and VARCHAR?
- What Are the Differences between DECIMAL and FLOAT?
|