Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
using random() #478596
11/13/19 02:11
11/13/19 02:11
Joined: Aug 2019
Posts: 22
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

Joined: Aug 2019
Posts: 22
hi, I'm testing the random number generator and I cannot seem to get random(1); to have an output other than zero.

I may be utilizing it incorrectly. The zorro.chm file saids

random(var max): var // suppose to return a number between 0 and max

my code looks like this:

function run()
{

int number = random(1);

if (number == 0) printf("\nZero");
if (number == 1) printf("\nOne");

}

Any ideas? Thanks!

Re: using random() [Re: felixfx] #478597
11/13/19 03:24
11/13/19 03:24
Joined: Aug 2019
Posts: 22
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

Joined: Aug 2019
Posts: 22
also, i noticed that the argument to the random() function is supposed to be a var and returns a var, but if i use

var number = random(1); it returns no output, which i also find odd.

Re: using random() [Re: felixfx] #478598
11/13/19 04:17
11/13/19 04:17
Joined: Aug 2019
Posts: 22
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

Joined: Aug 2019
Posts: 22
wow, i feel pretty dumb. the max argument means up to but not including. which means random(2) outputs 0 and 1.

Problem Solved


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1