[fpc-pascal] math round vs banker's round
Sven Barth
pascaldragon at googlemail.com
Wed Aug 14 09:34:14 CEST 2013
Am 14.08.2013 08:47, schrieb David Emerson:
> Thanks for the suggestions, guys!
>
> José Mejuto wrote:
> > SimpleRoundTo I think.
>
> But I want an integer result, and this returns a floating point.
>
> Sven Barth wrote:
>> Take a look at SetRoundMode in unit Math:
>> http://www.freepascal.org/docs-html/rtl/math/setroundmode.html
>
> After calling SetRoundMode(rmNearest);
> I find that system.round() is still doing banker's rounding. Am I
> missing something?
rmNearest is banker's rounding.
> I don't see this TfpuRoundingMode mentioned anywhere in the
> documentation, other than the "get" and "set" functions for the same.
> What does it effect?
Just click on TFPURoundingMode mentioned in the link.
>
> ...
> Anyway I guess I am going to have to write my own round() function :P
>
Seems so.
Regards,
Sven
More information about the fpc-pascal
mailing list