Collections:
Performing Comparison on Floating Point Numbers in SQL Server
How To Perform Comparison on Floating Point Numbers in SQL Server Transact-SQL?
✍: FYIcenter.com
Comparison operations on approximate (floating point) numbers are also easy to understand. Just watch out rounding operations performed during conversions. Here are two examples of floating point number comparisons:
-- Rounding during implicit conversion makes them equal
DECLARE @x FLOAT(24), @y FLOAT(24);
SET @x = 0.999999999E+00;
SET @y = 0.99999999E+00;
SELECT CASE WHEN @x <> @y THEN 'True' ELSE 'False' END;
GO
False
-- Floating point number literals have double precision
-- So no rounding
SELECT CASE WHEN 0.999999999E+00 <> 0.99999999E+00 THEN
'True'
ELSE
'False'
END;
GO
True
⇒ Performing Comparison on Date and Time Values in SQL Server
⇐ Performing Comparison on Exact Numbers in SQL Server
⇑ Boolean Values and Logical Operations in SQL Server Transact-SQL
2017-01-21, 3361🔥, 0💬
Popular Posts:
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...
How To Assign Debug Privileges to a User in Oracle? In order to run SQL Developer in debug mode, the...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...
How to obtain the number of rows found by the last SELECT statement using the FOUND_ROWS() function?...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...