T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- From: "Matt" <mattmorg55@xxxxxxxxx>
- Date: 30 Jan 2006 08:42:43 -0800
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
.
- Follow-Ups:
- Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- From: Erland Sommarskog
- Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- From: Hugo Kornelis
- Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- From: gabe101
- Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- Prev by Date: Re: ORDER BY in VIEW not working
- Next by Date: Re: SQL Server 2000 query time out option, what does it do?
- Previous by thread: Rqst for Inventory Database Best Practices
- Next by thread: Re: T-SQL ROUND(decimal, int) vs C# Round(Decimal, Int32)
- Index(es):
Relevant Pages
|