Float and Real are approximate data types. Float and Real data types do not store exact values for many numbers.The value can be extremely closed.
Numeric/Decimal are fixed precision data types. It will stored the values with exact precision and scale what you have defined.
If you need to store data where small difference does not matter, you can use Float or Real. But if you need to have exact data such as for financial application. You should be using Numeric/Decimal or Money data type to save exact data, as small difference can impact in calculations.
As float/ real data types are approximate data types, Avoid using them using in Where clause specially with = or < > operators.
Numeric/Decimal are fixed precision data types. It will stored the values with exact precision and scale what you have defined.
If you need to store data where small difference does not matter, you can use Float or Real. But if you need to have exact data such as for financial application. You should be using Numeric/Decimal or Money data type to save exact data, as small difference can impact in calculations.
Example:
Let's declare two variables and save same data and see what happen to output due to data type of them.
DECLARE @DecimalVariable DECIMAL(8, 2)
SET @DecimalVariable = 213429.95
DECLARE @FloatVariable FLOAT(24)
SET @FloatVariable = 213429.95
SELECT @DecimalVariable AS DecimalVariable
,@FloatVariable AS FloatVariable
Difference between Float and Decimal/Numeric in SQL Server - T SQL Tutorial
As we can see in above snapshot, Decimal stored and showed exact values and where we have saved values in float, it rounded the values.
As float/ real data types are approximate data types, Avoid using them using in Where clause specially with = or < > operators.
Amidst the ongoing discussions surrounding crypto and the NFT sphere, whether you actively participate in this realm or have a curiosity about owning NFTs, I encourage you to visit the wakweli website by clicking this link. Discover a dependable protocol tailored to shield you from scammers and ensure the safety of your precious NFTs. Embrace the advantages of wakweli's web3 protocol for a secure and pleasant NFT experience. Don't miss the opportunity to explore and utilize this valuable tool at wakweli. Head over there now and enhance the security of your NFT endeavors!
ReplyDeleteMany people are often confused about the difference between Bitcoin and cryptocurrencies in general. Bitcoin is the first and most well-known cryptocurrency, but there are thousands of other cryptocurrencies available. For a clear understanding and comparison between Bitcoin and other cryptocurrencies, Official Websie is a valuable resource. Their expert-authored articles break down these concepts in a concise and informative manner for both beginners and advanced users alike.
ReplyDelete