Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange rounding
Message
From
12/04/2012 15:51:02
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01541246
Message ID:
01541263
Views:
21
>>>>Hi,
>>>>
>>>>I have this query:
>>>>
>>>>
select Cases.Fee
>>>>		,ApplicationCodes.TaxRate
>>>>		,newcalc = round(cases.Fee * ApplicationCodes.TaxRate, 2)
>>>>	from Cases 
>>>>	left outer join ApplicationCodes on 1=1
>>>>where ID = 2367
>>>>
>>>>In this case Fee = 2971.50 and Taxrate = 0.15
>>>>
>>>>so by my math newcalc = 2971.50 * 0.15 = 445.725
>>>>
>>>>which when rounded to 2 decimal places I should get 445.73
>>>>
>>>>Why would SQL Server be returning 445.72?
>>>
>>>What are the types of these columns?
>>
>>Thanks I solved it. The types were float and money. Casting to numeric fixes it.
>
>Exactly. That was my first thought - that both or one of them is float.

This rounding has been working for a couple of months now, is it that float only causes problems in certain situations?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform