I have some floating field problem

i have 2 field , field A as float, field B as float

in a record field A has 0.15 value and field B has 0.15 value also (Using Select statement)

but when i use “Select fieldA – fieldB From tableName Where KeyField = Key” the result is 2.77555756156289E-17

i encountered the problem when i have unexpected result from my stored procedure that determine deviation of the two fields. i still dunno why this happening (i’m using sql server 2008)

]]>select Cos((90 – 38.588032) / (180 / PI())) * Cos((90 – 38.588032) / (180 / PI())) + Sin((90 – 38.588032) / (180 / PI())) * Sin((90 – 38.588032) / (180 / PI())) * Cos((-90.585533 – -90.585533) / (180 / PI()))

fails:

select Acos(Cos((90 – 38.588032) / (180 / PI())) * Cos((90 – 38.588032) / (180 / PI())) + Sin((90 – 38.588032) / (180 / PI())) * Sin((90 – 38.588032) / (180 / PI())) * Cos((-90.585533 – -90.585533) / (180 / PI())))

And just FYI, your blog has helped me SO VERY MUCH in my job as an analyst. Thank you thank you thank you!

]]>SELECT POWER (-15.0, 0.2)

you will get “An invalid floating point operation occurred.” error.

You’ll get the same error in all cases where the base is a negative number and exponent is not an integer.

]]>1. SELECT SQRT(5);

2. SELECT ACOS(3)

3. SELECT LOG(9);

Only number 2 [ACOS(3)] throws error, because we need to pass floating expression, alas passing the floating expression also throws error, please execute this one

SELECT ACOS(2.555665555)

But if execute this one…

SELECT ACOS(0.55555), the generated result is found, I meant the error is not thrown. So in case of ACOS fundtion we have to be cautious to choose the value.

Thanks

~~sp_who

Thanks for this article.

Regard$

Chirag Satasiya

It save my time..

Regards,

Infoyen