Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mixing variable types in a numerical calculation
(01-05-2021, 01:42 PM)patters Wrote: Incidentally, what happens when you multiple two UBYTES variables together, which one needs to become UINTEGER? Or is it both?

One is enough. ZX Basic will understand and promote the other one automatically.
Keep in mind that C compilers automatically promote *every* operand into "int" (which is the native word size of the architecture). Z80 "int" is 1 byte or 16 bytes depending on what you consider the "native integer" register size.
More info here:

I think using that strategy is a performance killer for the Speccy Sad  (Intel CPUs have 16, 32 and 64 bits with MUL-tiplication in hardware. That's another thing). My implementation will be that the type to be promoted will be the one expected in the LEFT part of the LET assignation (in your case, Integer).

Messages In This Thread
RE: Mixing variable types in a numerical calculation - by boriel - 01-05-2021, 01:51 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)