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

Random.int low byte always zero for large ranges in Core 5.1.1 #917

Closed
electronjoe opened this Issue Oct 31, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@electronjoe

electronjoe commented Oct 31, 2017

I came across this when verifying the randomness of my Elm application. I was using Random.Generate - but this caused me to explore in the REPL - and demonstrated unexpected behavior.

Note in the random output examples below
1870605312 = 0x6F7F2C00
-40506368 = 0xFD95EC00

In experimentation - all outputs appear to be 24 bits of randomness with a low byte of zero? Unless I'm somehow abusing things.

Random.step (Random.int Random.minInt Random.maxInt) (Random.initialSeed 352342343451)
(1870605312,Seed { state = State 271757466 483020887, next = , split = , range = })
: ( Int, Random.Seed )
Random.step (Random.int 0 Random.maxInt) (Random.initialSeed 352342343451)
(1870605312,Seed { state = State 271757466 483020887, next = , split = , range = })
: ( Int, Random.Seed )
Random.step (Random.int Random.minInt Random.maxInt) (Random.initialSeed 352342342)
(-40506368,Seed { state = State 1784235513 1655838864, next = , split = , range = })
: ( Int, Random.Seed )

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Oct 31, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Oct 31, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@electronjoe

This comment has been minimized.

Show comment
Hide comment
@electronjoe

electronjoe Oct 31, 2017

Additional information:
Browser: Chrome 61.0.3163.100 (Official Build) (64-bit)
OS: OSX Sierra 10.12.6

electronjoe commented Oct 31, 2017

Additional information:
Browser: Chrome 61.0.3163.100 (Official Build) (64-bit)
OS: OSX Sierra 10.12.6

@electronjoe

This comment has been minimized.

Show comment
Hide comment
@electronjoe

electronjoe Nov 1, 2017

Wanted to follow up for people who might come across this. I understand that mgold/elm-random-pcg is going to become mainline soon? I migrated to mgold/elm-random-pcg, it was completely API compatible with Core.Random - and resolved my issue.

electronjoe commented Nov 1, 2017

Wanted to follow up for people who might come across this. I understand that mgold/elm-random-pcg is going to become mainline soon? I migrated to mgold/elm-random-pcg, it was completely API compatible with Core.Random - and resolved my issue.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Nov 1, 2017

Member

Yes, that library will be in core in the next release of Elm. Using Max's library is a nice thing to do in the meantime.

Member

evancz commented Nov 1, 2017

Yes, that library will be in core in the next release of Elm. Using Max's library is a nice thing to do in the meantime.

@evancz evancz closed this Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment