Thanks for the tutorial, it was very helpful in implementing some double to long rounding, but there seems to be a bug in the bankers rounding function. It looks like this:
1 2
// If 'value' is exctly halfway between two integers
if ((value -(ipart +0.5)) < epsilon)
Should be:
1 2
// If 'value' is exctly halfway between two integers
if (fabs(value -(ipart +0.5)) < epsilon)
It even looks like the brackets were there and the fabs was removed? Anyway, without them (assuming epsilon is positive) any value where the original value is less than n.5 was triggering as an edge case and then changing any odd numbers, including whole numbers. In my case, '15' was getting converted to 16, since 15 - 15.5 is -0.5 which, of course, is less than my epsilon.