Log in

View Full Version : value of random(Y)


spyhawk
25th January 2008, 08:14
What's the valid range for a random function, e.g. gprm(x) = (rnd) Y ? Is the output 0...Y-1, 1...Y, 0...Y, or 1...Y-1? I'm not quite sure which one. Got a game DVD to fix. TIA.

Edit: I think it's 1...Y. Just need to confirm.

blutach
25th January 2008, 11:39
Yup.

Regards

r0lZ
25th January 2008, 11:41
You are right. The returned value is between 1 and the value of the operand.

Note that the result of gprm(x) ?= (rnd) 0 is undefined. Most software players return 1, but my Sony returns 0. Anyway, you should always use an operand > 1.

spyhawk
25th January 2008, 19:38
Thanks guys. Then I got a bunch of these to correct.