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: Wednesday, May 22, 2013 1:10 PM
Points: 2,673, Visits: 2,418
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: Tuesday, May 21, 2013 10:53 AM
Points: 1,662, Visits: 1,709
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-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 20, 2012 10:20 AM
Points: 197, Visits: 98
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, May 13, 2013 11:21 AM
Points: 2,163, Visits: 2,148
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: Yesterday @ 10:25 AM
Points: 18,754, Visits: 12,337
Thanks for the QOTD



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


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
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, July 25, 2012 9:04 PM
Points: 542, Visits: 187
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: Monday, September 17, 2012 7:30 AM
Points: 1,038, Visits: 679
Thanks! it really helped me to understand clearly
Post #1007449
Posted Monday, November 01, 2010 8:09 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: 2 days ago @ 1:33 AM
Points: 738, Visits: 1,126
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