Home Forums SQL Server 7,2000 T-SQL Banker''s rounding in T-SQL (like Math.Round in .NET) RE: Banker''''s rounding in T-SQL (like Math.Round in .NET)

  • Thanks Jeff. But none of them is banker's rounding.

    Banker's rounding bahaves like arithmetic rounding with one exception: if value is halfway between two numbers, one of which is even and the other odd, then the even number is returned.

    Examples of banker's rounding (results of Math.Round in .NET):

    Math.Round(3.454,2) -> 3.45

    Math.Round(3.455,2) -> 3.46

    Math.Round(3.445,2) -> 3.44

    Math.Round(3.456,2) -> 3.46

    Pay your attention on lines 2 and 3. Result depends on wether the second digit after dot is even or odd.

    Complexity is that I perform calcualtions with double and finaly need to round the result. So values can have lots of digits after dot and I have to round them one by one to the precision digit.