Click here to Skip to main content
16,012,508 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I write a Sql Query for some calculation
SQL
Declare @fltAdjQuantity as float
Set @fltAdjQuantity = 1.0714285714285714
select @fltAdjQuantity
select @fltAdjQuantity - 1


@fltAdjQuantity = 1.0714285714285714 and when I deducted it with (-1) It will give 7.1428571428571397E-2 instead of 0.0714285714285714 [1.0714285714285714 - 1 = 0.0714285714285714 ].

Please Help me i am waiting.....
Posted
Comments
Sergey Alexandrovich Kryukov 20-Mar-12 2:51am    
Not a question.
--SA

There is nothing wrong. This is expected result, with expected accuracy. Don't forget, the calculations are approximate. You can also present the numeric values in the string form using format you need through double.ToString(string format). Please see also:
http://msdn.microsoft.com/en-us/library/system.double.tostring.aspx[^],
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^],
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^].

—SA
 
Share this answer
 
Hi,

SQL
Declare @fltAdjQuantity as float
Set @fltAdjQuantity = 1.0714285714285714
select @fltAdjQuantity
select @fltAdjQuantity - 1


I checked you above query and it is giving me 0.0714285714285714 which you need as an answer.

Pls elaborate your question.
 
Share this answer
 
Comments
P.S Vijay 20-Mar-12 3:37am    
I am using Sql 2000

and I am getting 7.1428571428571397E-2 please help me and take me out
from here
Bernhard Hiller 20-Mar-12 3:44am    
Don't you sse that that is the same result, just in different formatting? See SAKryukov's answer above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900