ehBASIC - random function

49 views
Skip to first unread message

Steve Crompton

unread,
Oct 12, 2022, 8:39:39 AM10/12/22
to retro-comp
Greetings folks

Am I missing a trick here:

10 PRINT RND(1)
20 PRINT RND(1)
30 PRINT RND(1)
40 PRINT RND(1)

RUN

 .01064253
 .01064253
 .01064253
 .01064253

I expected 4 random numbers to be printed but no, Am I doing something wrong? or is ehBASIC flawed in this respect

Steve


Steve Crompton

unread,
Oct 12, 2022, 8:56:24 AM10/12/22
to retro-comp
10 PRINT RND() gives syntax error

Ed Porter

unread,
Oct 12, 2022, 9:05:45 AM10/12/22
to retro...@googlegroups.com
See XKCD 221. https://xkcd.com/221/


http://www.6502.org/source/monitors/ehbasic/ehbasic.html says
"RND(<expression>)
Returns a random number in the range 0 to 1. If the value of
<expression> is non zero then it will be used as the seed for the
returned pseudo random number otherwise the next number in the sequence
will be returned. "

so 1 is the seed for the next round. Try rnd(0).

-ed

Steve Crompton

unread,
Oct 12, 2022, 9:20:07 AM10/12/22
to retro-comp
Thank You - RND(0) does the trick, I used RND(1) from another flavour of basic - I guess it is different there
Reply all
Reply to author
Forward
0 new messages