T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)



Anybody noticed that SQL Server rounds up if the value is half way
between two rounded values, but C#'s Decimal.Round(Decimal,Int32)
rounds to nearest even number?

>>From MSDN: "When d is exactly halfway between two rounded values, the
result is the rounded value that has an even digit in the far right
decimal position. For example, when rounded to two decimals, the value
2.345 becomes 2.34 and the value 2.355 becomes 2.36. This process is
known as rounding toward even, or rounding to nearest."

I perform the same calculation sometimes on the web server in C# and
sometimes at the database in T-SQL, but want to get the same result
from both calculations. Could anybody offer any strategies for dealing
with this?

Thanks ~ Matt

.



Relevant Pages

  • Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
    ... >Anybody noticed that SQL Server rounds up if the value is half way ... >known as rounding toward even, or rounding to nearest." ... SQL Server ...
    (comp.databases.ms-sqlserver)
  • Int rounding down (calculated) whole numbers
    ... I have a function during which a line passes a calculation to an integer, ... A function is required to round times to the nearest x mins (this element ... ' * mins past is used to round to nearest mins past the hour ... dteHighTime = dteHighTime - dblStdMin ...
    (microsoft.public.access.modulesdaovba)
  • Re: The moment the willing suspension of disbelief died
    ... The language is definitely not greek. ... there is a single character for 30, and a single character for 10, ... In fact rounding off to the nearest 10 is perfectly reasonable ...
    (rec.arts.sf.written)
  • Re: converting points to centimeters...
    ... I suppose that Word's rounding to the nearest ... I'm not comfortable with the rounding because it's not controllable - it's ... solution has to be Word 97 compatible and I don't believe there's a Round ... > The problem is not the conversion itself, but the act that Word rounds the ...
    (microsoft.public.word.vba.general)
  • Re: Dmax for nearest date
    ... No one is suggesting that you change the table, ... I'm trying to identify the nearest date to today. ... The query that the report is created from does a date calculation. ...
    (microsoft.public.access.reports)