[fpc-devel] Invalid floating point operation - roundto

tomek at ump.edu.pl tomek at ump.edu.pl
Thu Mar 7 14:01:24 CET 2013


I don't Get It.
Right parameter is TRoundToRange not single,double or extended.
In that case howto get roundto with extended precision ?
function RoundTo(const AVAlue: Extended; const Digits: TRoundToRange):
Extended;


2013/3/6 Jonas Maebe <jonas.maebe at elis.ugent.be>:
>
> On 22 Feb 2013, at 13:30, tomek at ump.edu.pl wrote:
>
> s1,s2: extended;
>
> s1:=291.022;
> s2:=roundto(s1,-30);   //TRoundToRange = -37..37;
>
> give me Invalid floating point operation.
>
> I see that roundto goes to single instead of extended. But why ?
>
>
> Because overload selection is based on parameter matching from right to
> left, and -30 can be exactly represented using "single" and hence is
> converted to that type by the compiler when it has to turn it into a
> floating point constant.



More information about the fpc-devel mailing list