Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data type choice: float or decimal

Status
Not open for further replies.

mbabcock

Programmer
Jul 25, 2006
32
US
What are the ramifications of choosing the specific data type of these two (float or decimal)? I need to store numerics with known decimal widths, and then do calculations on them later (multiplying and adding specifically) inside UDFs/stored procs.

Tia!
--Michael
 
See Books Online topic, data types-SQL Server, decimal.

Essentially
The decimal data type can store a maximum of 38 digits, all of which can be to the right of the decimal point. The decimal data type stores an exact representation of the number; there is no approximation of the stored value.
...
The float and real data types are known as approximate data types.
...
do not use these data types when exact numeric behavior is required, such as in financial applications, in operations involving rounding, or in equality checks.
...
Avoid using float or real columns in WHERE clause search conditions, especially the = and <> operators. It is best to limit float and real columns to > or < comparisons.
 
From 2000BOL: Approximate number data types for use with floating point numeric data. Floating point data is approximate; not all values in the data type range can be precisely represented.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top