Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Are all rounds created equal Expand / Collapse
Author
Message
Posted Wednesday, October 13, 2010 6:46 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 6:02 PM
Points: 2,818, Visits: 2,560
Interesting question. I thought all Microsoft software did banker's rounding. Thanks.
Post #1003546
Posted Wednesday, October 13, 2010 8:49 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 9:12 AM
Points: 1,676, Visits: 1,755
Daniel Bowlin (10/13/2010)
Interesting question. I thought all Microsoft software did banker's rounding. Thanks.

It is flexible. CLR procedures in SQL Server, any .NET code can use one of the two MidpointRounding enum values as a mode parameter value of the of the Math.Round method:

Math.Round(4.5, 0, MidpointRounding.AwayFromZero); -- 5
Math.Round(4.5, 0, MidpointRounding.ToEven); -- 4

Oleg
Post #1003704
Posted Wednesday, October 13, 2010 1:21 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 25, 2013 9:09 AM
Points: 216, Visits: 118
Thanks for the comments.

In a view SQL Server returned n.n where in query analyzer it returned n.n0 for each.

My main point was to showcase that there is disparity in programs as to how rounding is performed. Logic or specifications taken at face value (Round the average tax to the nearest tenth) can create differences in results. If you have an application performing the rounding and storing it in the db and run a periodic db script to verify you may get answers that result in 'random' discrepancies.

Tim

There are only 10 types of people that understand binary, those that do and those that do not.
Post #1003937
Posted Wednesday, October 13, 2010 6:16 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 16, 2014 9:38 AM
Points: 2,163, Visits: 2,189
Thanks for the question.

As a note I have always hated the round "to even" method that Microsoft sometimes uses.
Post #1004068
Posted Monday, October 18, 2010 10:17 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 1:55 PM
Points: 21,638, Visits: 15,305
Thanks for the QOTD



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1006348
Posted Tuesday, October 19, 2010 1:14 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Sunday, November 17, 2013 11:53 AM
Points: 623, Visits: 237
Awesome Question...
Post #1006742
Posted Tuesday, October 19, 2010 10:46 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 21, 2014 5:29 AM
Points: 1,179, Visits: 786
Thanks! it really helped me to understand clearly
Post #1007449
Posted Monday, November 1, 2010 8:09 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, August 21, 2014 2:40 PM
Points: 829, Visits: 1,375
Nice one. I hope 2.50 and 2.5 or 3.60 and 3.6 are taken as same!

Thanks.
Post #1013841
Posted Friday, November 30, 2012 2:16 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, February 20, 2013 1:45 AM
Points: 616, Visits: 97
+1:)
Post #1391117
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse