Forum
Randomize problem? (*solved*) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Randomize problem? (*solved*) (/showthread.php?tid=502)



Randomize problem? (*solved*) - na_th_an - 09-27-2012

I've searched the forums about this issue but I haven't found anything.

I gather that RANDOMIZE uses the timer to seed the variable, doesn't it? So this program, depending on the time I take to press the key, should render different numbers. Well, the result is always 6.

Code:
Print "PRESS KEY": Pause 0
Randomize
Let a = Int (Rnd * 10)
Print a

If I try...

Code:
'''
Dim a as uByte
Dim b as uByte
Print "PRESS KEY": Pause 0
b = Peek 23672
Print "FRAMES LSB IS "; b
Randomize b
let a = Int (Rnd * 10)
Print a

The result is always 0, no matter which value is in b. This shouldn't be!

I'm using 1.2.9-s888


Re: Randomize problem? - JBGV - 09-27-2012

Hello Na_th_an !

With 1.2.9 (Current Stable Version) seems to work well :roll:


Re: Randomize problem? - boriel - 09-27-2012

Sorry for the delay (I'm quite busy these days Sad ).
As JGBV says, try the latest version. 1.2.9 changes the RND generator (Britlion proposed a better & faster generator), and I remember I had also to fix-up the RANDOMIZE routine in the meanwhile (you might have an intermediate version).


Re: Randomize problem? - na_th_an - 09-28-2012

Thanks, I didn't realise that the stable version was updated, my fault Smile
Cheers!

BTW, we have a new release, complete with new library, very soon.


Re: Randomize problem? - britlion - 09-28-2012

Yes. We're on this one, now.

<!-- m --><a class="postlink" href="http://xkcd.com/221/">http://xkcd.com/221/</a><!-- m -->


Re: Randomize problem? - boriel - 09-29-2012

britlion Wrote:Yes. We're on this one, now.

<!-- m --><a class="postlink" href="http://xkcd.com/221/">http://xkcd.com/221/</a><!-- m -->
LOOOOL! :lol:


Re: Randomize problem? (*solved*) - na_th_an - 10-01-2012

The funny thing is, in case you don't know, that joke is about the reason why the PS3 was hacked last year. The random number to generate the signatures was always 4.


Re: Randomize problem? (*solved*) - boriel - 10-01-2012

na_th_an Wrote:The funny thing is, in case you don't know, that joke is about the reason why the PS3 was hacked last year. The random number to generate the signatures was always 4.
:mrgreen:
Well, I knew It was related to PS3 (I own one) the the random number bug, but didn't know it was just that!