Home Forums SQL Server 7,2000 T-SQL Round to Even (aka Banker''s Rounding) - The final function RE: Round to Even (aka Banker''''s Rounding) - The final function

  • While this is a trick on his part, I actually agree with him, even though he'll disagree with what this function should do with it (he can take that to the other thread). What he's not telling you is that SQL Server will do an implicit round on this number before it ever gets to the function, so the function will actually only receive .125 as a parameter, instead of its actual value which is something like 1.2503125781445361340335083770943e-6. We should indeed be able to handle that, and based on the rules above (which is what this thread is about), should return .12.

    On the other hand, if the function actually receives the value 1.2503125781445361340335083770943e-6 from SQL Server, then we should return .13, based on the rules above.

    So yes, he's correct, we should be able to handle that. It's just that we'll handle it differently depending on whether we get the implicitly rounded version or the more accurate version of the number, as that's how Banker's rounding is designed, again, as noted above.