error 20: Type mismatch in 'pInt = @i + int(20 * 0.5)'
Code: Select all
dim as integer i
dim as integer ptr pInt
pInt = @i + 10
pInt = @i + int(20 * 0.5)
Code: Select all
pInt = @i + cast(integer, int(20 * 0.5))
Code: Select all
dim as integer i
dim as integer ptr pInt
pInt = @i + 10
pInt = @i + int(20 * 0.5)
Code: Select all
pInt = @i + cast(integer, int(20 * 0.5))
I understand the legacy. I started with QBASIC myself. Only today (after almost 25 years!) I learned that int(...) is different then I always thought.caseih wrote:Indeed that does seem a rather strange choice at first blush. But it's not FB's fault. This is the way QuickBasic and other BASICs have done it for decades. Even more confusing, if you come from other languages, then Int() would almost always be not what you'd want. Fix() would probably be more appropriate. But like Int() it returns the same type it was given. In an ideal world, Int() would be renamed Floor(), and Int() would do what you expect, which is the same as Fix() but always returning an integer.
Code: Select all
declare function Fix ( byval number as single ) as single
declare function Fix ( byval number as double ) as double
declare function Fix ( byval number as integer ) as integer
declare function Fix ( byval number as uinteger ) as uinteger