Search code examples
freepascallazarus

turning off RoundTo uses the Banker's rounding


It seems that when using the function RoundTo (math unit) it uses the Banker's rounding, for example my column.point = 76.5 returns 76 instead of 77. I use Lazarus 1.8.2 FPC 3.0.4

result:= Double(column.point * scale)//76.5; 
SetRoundMode(rmNearest);
result:= RoundTo(result,-decimalen)//76;

how can I turn off Banker's rounding so the rounding for 76.5 ~= 77 or alternative solutions perhaps? if decimal point is .5 the use SetRoundMode(rmup) instead? thanks guys


Solution

  • SimpleRoundTo function did the trick. Thanks all for your help.