Skip to content
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

JS: Random function in Math library not working right. #61

Closed
corrupt3k opened this issue Mar 30, 2024 · 3 comments · Fixed by #67
Closed

JS: Random function in Math library not working right. #61

corrupt3k opened this issue Mar 30, 2024 · 3 comments · Fixed by #67
Assignees
Labels
bugfix Something isn't working

Comments

@corrupt3k
Copy link

corrupt3k commented Mar 30, 2024

Describe the bug.

Generating random numbers within a defined range is not working. Numbers are generated outside of the range sometimes.

Reproduction

let math = require("math");

function getRandomArbitrary(min, max) {
return math.floor(math.random() * (max - min + 1)) + min;
}

while (1 === 1) {
let randomIndex = getRandomArbitrary(0, 23);
print(randomIndex);
delay(1000);
}

Target

No response

Logs

No response

Anything else?

No response

@corrupt3k corrupt3k changed the title JS: Math library not working right. JS: Random function in Math library not working right. Mar 30, 2024
@SuperJakov
Copy link

SuperJakov commented Apr 1, 2024

By running this script:

let math = require("math")

while (true) {
print(math.random())
delay(500)
}

We can see that sometimes, it returns values higher than 1

Devbuild version: momentum dev c633b0f 1st April of 2024

@Willy-JL
Copy link
Member

Willy-JL commented Apr 2, 2024

can you check on #67 ?

@Willy-JL Willy-JL self-assigned this Apr 2, 2024
@Willy-JL Willy-JL added bugfix Something isn't working release-pending This is done, will be in next release labels Apr 2, 2024
@Willy-JL Willy-JL reopened this Apr 2, 2024
@Willy-JL
Copy link
Member

Fix was released in mntm-002

@Willy-JL Willy-JL removed the release-pending This is done, will be in next release label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants