Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
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
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (vicknick, howardR, sleakz), 674 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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