[Gambas-user] Bug in code parser

Benoît Minisini gambas at ...1...
Mon Apr 6 01:41:12 CEST 2009


> I discovered a funny bug in the code parser...
> If I write:
>
> DIM s AS Integer
> s = Int(Rnd(0, 10)) MOD 3
>
> I get:
> Type mystmatch: wanted integer, got float instead. But Int() should return
> an integer...
>
> But if I write:
>
> DIM s AS Integer
> s = Int(Rnd(0, 10))
> s = s MOD 3
>
> the code is executed without problems :-)

This is not a bug: Int() really returns a float. This float has no decimal 
part, but it is a float anyway. 

The MOD operator just does not convert its argument by default, and so always 
expect a pure integer.

It may change in the future, as there is a request for having a MOD operator 
that deals with Float too.

REgards,

-- 
Benoît




More information about the User mailing list