Export (0) Print
Expand All

System.Math Methods

The .NET Framework has different rounding semantics from SQL Server. The Round method in the .NET Framework performs Banker's rounding, where numbers that ends in .5 round to the nearest even digit instead of to the next higher digit. For example, 2.5 rounds to 2, while 3.5 rounds to 4. (This technique helps avoid systematic bias toward higher values in large data transactions.)

In SQL, the ROUND function instead always rounds away from 0. Therefore 2.5 rounds to 3, contrasted with its rounding to 2 in the .NET Framework.

LINQ to SQL passes through to the SQL ROUND semantics and does not try to implement Banker's rounding.

Show:
© 2014 Microsoft