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: Friday, December 12, 2014 8:24 AM
Points: 2,818, Visits: 2,567
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:13 AM
Points: 1,676, Visits: 1,761
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: Friday, October 17, 2014 2:43 PM
Points: 216, Visits: 119
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: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
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


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 2:39 PM
Points: 18,064, Visits: 16,108
Thanks for the QOTD



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
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: Wednesday, December 10, 2014 10:49 AM
Points: 1,194, Visits: 791
Thanks! it really helped me to understand clearly
Post #1007449
Posted Monday, November 1, 2010 8:09 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, December 19, 2014 4:41 AM
Points: 1,048, Visits: 1,558
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