Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First RND call is ignoring RANDOMIZE, subsequent calls are fine (*solved*)
I have noticed while testing my program that the very first random number is always the same when the compiled program is loaded into an emulator. Subsequent ones are indeed random.

That first result is normal - you might think - because RND will be invoked at the same number of ticks after power-on each time. However, I use RANDOMIZE after an INPUT (which won't always be submitted at a consistent time by the user) before the first RND in the program is requested, so this should not happen. I presume this is a bug because after the first RND, it behaves as normal. If I deliberately insert a dummy RND before the RND values I need, then my program runs with the expected randomness.

Simple test case which demonstrates the issue:

#include <input.bas>

PRINT INT (RND*100) 'this number is consistent every time the emulator is launched with the tap file
PRINT INT (RND*100) 'this number will be random

When I run the tap file in Fuse on Mac OS I usually get 60 for the first random number. Very occasionally I get 61 though, so that may help for debugging. It's always those two values though. The second number will be in the range 0-99 as expected.

This issue is present in release version 1.14 and in 1.14beta9

Messages In This Thread
First RND call is ignoring RANDOMIZE, subsequent calls are fine (*solved*) - by patters - 01-13-2021, 02:38 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)