Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9190

Re: Trying to limit the fidelity (to 2 decimal places) of a calculated value?

$
0
0

Hi Everyone,

 

Using the ROUND() function only removes the accuracy of the result returned. E.g.: if I have 12.8564525242 and I apply a rounding to two decimal places what I will see it 12.8500000000, instead of what I want to see which is 12.85.

 

The only way I found around this was to cast both the dividend and the divisor as floats. I then followed this by casting the result to decimal(15,2), and this did give me an actual result that was only two decimal places long.

 

I have come to believe that the rules affecting T-SQL regarding division mean that when dividing one decimal number by another the fidelity is increased (exponentially...it would seem!).

 

Kind Regards,

 

David


Viewing all articles
Browse latest Browse all 9190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>