So, I'm doing a little Delphi conversion just now and while looking through the code I came over a little bit which didn't quite make sense. Rounding floating point numbers into integers. Now my default has always been to truncate for rounding. Not only is it faster (by far!) but it's easy to predict, and everyone understands it. Now, Delphi's rounding...wow... it's nuts!
Dephi seem to have gone out of their way to complicate things, and I can't figure out why. Anyway, after doing a quick search heres the Delphi rules...
The Round function rounds a floating point Number to an Integer value.
The rounding uses Bankers rules, where an exact half value causes a rounding to an even number:
12.4 rounds to 12
12.5 rounds to 12 // Round down to even
12.6 rounds to 13
13.4 rounds to 13
13.5 rounds to 14 // Round up to even
13.6 rounds to 14
Now...why o WHY would you do that.... Round .5 to EVEN! What! Nuts I tellz ya...