# Re: [Ql-Users] Function type error

```I couldnt resist wading in here. Regarding Michael's original question the
```
100 :
110 a = 330.7: b = 440.7
120 PRINT #0, Min_Int%(a, b), Mint%(a, b)
130 PAUSE -1
140 STOP
150 :
160 DEFine FuNction Min_Int%(x%,i)
170  IF x% < i : RETurn x% : ELSE : RETurn i
180 END DEFine
190 :
200 DEFine FuNction Mint%(x%, i)
210 LOCal a%
220 IF x% < b: a% = x%: ELSE : a% = i
230 RETurn a%
240 END DEFine Mint%
250 :

Dilwyn's solution is somewhat different in that a% = INT(a) <> a% = a, as
can be verified by running the routine below:

100 CLS: FOR i = 4 TO 5.1 STEP .1: PRINT Flint(i)! i
110 DEFine FuNction Flint(a%)
120 LOCal x%
130 x% = a%
140 IF INT(a%) = x%: RETurn 1
150 RETurn 0
160 END DEFine Flint
170 :

(But replacing the line 100 above with the line below, wheres the logic in
this:
100 CLS: FOR i% = 4 TO 5.1 STEP .1: PRINT Flint(i%)! i%
? Probably the result of hitting a RIRO design paradigm?)

Per

On 10 August 2017 at 18:22, Dilwyn Jones via Ql-Users <
ql-users@lists.q-v-d.com> wrote:

> The fact that the function name ends in % doesn't seem to make it an
> integer function (although the QL user guide says that "the type of data
> returned by the function is indicated by the type appended to the function
> identifier") any more than  parameter names have no type until they are
> set, so parameter x% could be float or integer, depending on what it is
> made when parameters are passed.
>
> As a workaround, add INT in line 160
>
> 160 IF INT(x%) < i : RETurn INT(x%) : ELSE return INT(i)
>
> Dilwyn
>
> -----Original Message----- From: Michael Bulford via Ql-Users
> Sent: Thursday, August 10, 2017 5:54 PM
> To: ql-users@lists.q-v-d.com ; ql-users-requ...@lists.q-v-d.com
> Subject: [Ql-Users] Function type error
>
>
> Hi all,
> I've no idea whether this has been mentioned before, but consider this …
> 100 :110 PRINT #0, Min_Int%(330.7, 440.7)120 PAUSE -1130 STOP140 :150
> DEFine FuNction Min_Int%(x%,i)160  IF x% < i : RETurn x% : ELSE : RETurn
> i170  END DEFine The correct result should be 331, sincethis is an integer
> function.On QPC2, SBASIC gives the result as 330.7QLiberator likewise also
> gives 330.7 Can anything be done? Michael
>
> _______________________________________________
> QL-Users Mailing List
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
> _______________________________________________
> QL-Users Mailing List
_______________________________________________
QL-Users Mailing List```