11-07-2016, 10:32 PM
Haplo Wrote:Hello, the version is 1.4.0-s1967Phew!! :roll:
It's not a bug (BTW the latest version is 1.4.0-s1968).
The problem is you are declaring a and b as ubyte, and ZX Basic does not typecast by default to Uinteger if the result is uinteger.
Your code:
Code:
cls
dim a,b as ubyte
dim dw1,dw2 as uinteger
b=5
a=100
valor=a*b
Some compilers (e.g. most C Compilers) detects that 'valor' is Uinteger and will typecast A and B to Uinteger.
ZX Basic does not, for performance reasons (Z80 and 48k are so tiny... :roll: )
You can overcome this by doing an Explicit CAST. Try this:
Code:
cls
dim a,b as ubyte
dim dw1,dw2 as uinteger
b=5
a=100
valor=CAST(Uinteger, a) * b : REM Explicit CAST of a (or b) will convert all the expression to Uinteger
Most C compilers do that automatically. ZXBasic needs you to explicit use CAST in one of the operands.
I'm thinking whether or not ZX Basic should follow the policy of the other compilers, but this will reduce performance (and take more memory).