Gamestudio Links
Zorro Links
Newest Posts
Bmap creation - wrong Alpha values
by txesmi. 12/11/19 12:43
A9
by preacherX. 12/11/19 11:01
Error Message 010: invalid stops
by Volker. 12/11/19 08:25
AssetFix & Assets.csv
by MatPed. 12/11/19 07:03
How to handle profit in a TMF during training
by StefanCGN. 12/09/19 20:09
Simulate complex commission costs [Test]
by AndrewAMD. 12/09/19 13:52
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
6 registered members (3run, AndrewAMD, Volker, Quad, PabloMF, 1 invisible), 802 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
timW, PabloMF, deepscreener, wzschultz, Alit
18342 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: 19
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

Joined: Aug 2019
Posts: 19
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: 19
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

Joined: Aug 2019
Posts: 19
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: 19
F
felixfx Offline OP
Newbie
felixfx  Offline OP
Newbie
F

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

Problem Solved


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1