Fixed: random(max = 0) not returning 0 (zero)#9
Fixed: random(max = 0) not returning 0 (zero)#9uifdev wants to merge 1 commit intoopenmultiplayer:masterfrom
Conversation
|
Why should it be zero? There are no numbers in the range 0 ... -1, so this should be an error, otherwise 0 is about as valid as any other number. |
|
Generally I agree with @IS4Code , but a fix like this would break backwards compatibility and is therefore pretty risky :D So i think crashing would be the worst possible thing to do, even if it feels correct. Might this be a thing for the fixes include? |
|
I agree with marcel here, it's not conformant but a lot of this fork diverged anyway so it doesn't really matter, plus I doubt any sampers actually care about what the spec says! There may be people who have written code based on observed assumption that passing 0 returns a "random" number so I think it's best to just leave it as-is. |
|
Wdym? Nothing should crash? (Bro deleted his comment, I am not crazy, I swear) |
random(max = 0) returns an arbitrary number. This does not conform to the PAWN Language Guide (February 2024, p. 108), according to which it should return "a pseudo-random number in the range 0 ... max-1", which in this case should be 0 (zero).