Skip to content

Fixed: random(max = 0) not returning 0 (zero) #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uifdev
Copy link

@uifdev uifdev commented Feb 9, 2025

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).

@IS4Code
Copy link

IS4Code commented Feb 9, 2025

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.

@Bios-Marcel
Copy link

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?

@Southclaws
Copy link
Contributor

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.

@Bios-Marcel
Copy link

Bios-Marcel commented Feb 10, 2025

Wdym? Nothing should crash? (Bro deleted his comment, I am not crazy, I swear)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants