Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Out of memory when using uinteger array (*solved*)
#20
Darkstar Wrote:I think I get it now, the first line only gives 86 possible combinations.
That's it!

In fact, better do CAST(Ubyte, Rand()). This is the fastest way, however, many random number generators suggest to use a middle 2nd byte, so:
Code:
Function Fastcall RandByte as Ubyte
    asm
    call RAND  ; 32 bit rand number in de:hl
    ld a, e       ; take the 2nd higher byte; Ubyte functs returns result in A reg.
    end asm
End Function
Another way is to use AND 0xFF (byte), or AND 0xFFFF (ubyte), but CAST is the best way (or just direct assignement).
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)