[fpc-devel] Invalid floating point operation - roundto
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Mar 6 10:15:57 CET 2013
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.
Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130306/7ce537e7/attachment.html>
More information about the fpc-devel
mailing list