Home » » Issue with Abs function in SQL Server?

Issue with Abs function in SQL Server?

Written By M.L on திங்கள், 24 அக்டோபர், 2011 | அக்டோபர் 24, 2011

I have a query for Abs function of SQL Server 2008. I am passing the following parameters in my two of the scenario:

1st Scenario(in debug mode) -

@value1 float =  3.000000000000000e-002 (which is 0.03 in the table field)
@value 2 float = 2.000000000000000e-002 (which is 0.02 in the table field)
Select @Result float = Abs(@value1 -@value 2 )
                   =  3.000000000000000e-002 - 2.000000000000000e-002
                  =  9.999999999999999e-003

2nd  Scenario(in debug mode) -

@value1 float =  4.000000000000000e-002(which is 0.04 in the table field)
@value 2 float = 3.000000000000000e-002(which is 0.03 in the table field)
Select @Result float = Abs(@value1 -@value 2 )
                   =  4.000000000000000e-002 - 3.000000000000000e-002
                  =  1.000000000000000e-002

So, my question is why Abs function is returning two different values when the value difference is same in both the scenarios ? Could you please help me to solve this problem?

0 comments:

கருத்துரையிடுக

Popular Posts

General Category