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

Random.rand(max : Float32) should return a Float32, not Float64 #9940

Closed
j8r opened this issue Nov 20, 2020 · 1 comment · Fixed by #9946
Closed

Random.rand(max : Float32) should return a Float32, not Float64 #9940

j8r opened this issue Nov 20, 2020 · 1 comment · Fixed by #9946

Comments

@j8r
Copy link
Contributor

j8r commented Nov 20, 2020

Random.rand takes any Float and returns a Float64. to_f32 is needed to cast back to a Float32.
To be consistent with other methods taking integers, like Random.rand(max : Int) : Int, which returns the same type as the given integer, I suggest to have the method returning a Float32 if one was given.

Example of the current behavior:
p typeof(Random.rand(1_f32)) #=> Float64

@straight-shoota
Copy link
Member

Sounds very reasonable to return the same type that was given.

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

Successfully merging a pull request may close this issue.

2 participants