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

Make Random.rand(max : Float32) return a Float32 #9946

Conversation

j8r
Copy link
Contributor

@j8r j8r commented Nov 20, 2020

Resolves #9940

src/random.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric labels Nov 21, 2020
@j8r
Copy link
Contributor Author

j8r commented Jan 27, 2021

Can we move forward? I've done like the existing Float64 method with the mantissa exclusion. If this logic is correct, both method will. Otherwise, both will be wrong.

@beta-ziliani
Copy link
Member

After reading the comments, I think it's best to have this merged with the right number for the mantissa (note the last part of Oleh's comments). Can you fix that @j8r ? The random generator for Float64 isn't perfect, and so will be the one for Float32. It will still work for the most applications. It's best to have a dedicated shard for better random support.

@straight-shoota straight-shoota added this to the 1.3.0 milestone Oct 26, 2021
@straight-shoota straight-shoota merged commit 24b807f into crystal-lang:master Oct 28, 2021
@beta-ziliani beta-ziliani modified the milestones: 1.3.0, 1.2.2 Oct 29, 2021
@oprypin oprypin modified the milestones: 1.2.2, 1.3.0 Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random.rand(max : Float32) should return a Float32, not Float64
4 participants