![]() |
|
Multiplication result greater than 255 in UINTEGER var - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://forum.boriel.com/forumdisplay.php?fid=16) +---- Thread: Multiplication result greater than 255 in UINTEGER var (/showthread.php?tid=846) |
Multiplication result greater than 255 in UINTEGER var - LukeBord1 - 2018-05-30 First of all, as usual, sorry if this was discussed before... at a first sight around the arguments, i didn't find a solution. The below code works till the "32*(PEEK 32044)" multiplicaton returns a a value within 255, but why?... Code: REM 32043 and 32044 store line and column valuesRe: Multiplication result greater than 255 in UINTEGER var - LukeBord1 - 2018-05-30 ...damn, it isn't the first time i find the solution my own, just after posting the topic here... :lol: So here's the way to declare the operations: Code: DIM a AS UINTEGERThanks for watching :oops: Re: Multiplication result greater than 255 in UINTEGER var - boriel - 2018-05-30 Hi No worries. Yes it's been discussed before and will be changed in future releases. ZXbasic does type promoting sometimes but not always. So by default when multiplying two Byte values it will get the result as a Byte hence truncating the result. You can enforce a typecast with CAST of one of the multiplication operands and this should fix it. Try using CAST(Uinteger, 32) and tell me. :wink: |