# Random numbers in \[0.f0,1.f0\]

**URL:** https://discourse.julialang.org/t/random-numbers-in-0-f0-1-f0/30926
**Category:** GPU
**Created:** [November 10, 2019, 5:31pm UTC](https://discourse.julialang.org/t/random-numbers-in-0-f0-1-f0/30926 "2019-11-10T17:31:00Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [November 10, 2019, 5:51pm UTC](https://discourse.julialang.org/t/random-numbers-in-0-f0-1-f0/30926/2 "2019-11-10T17:51:41Z")

</div>

you can try to do something like this:

> [@GPU randn way slower than rand?](https://discourse.julialang.org/t/gpu-randn-way-slower-than-rand/18236/3):
>
> Hi Tim, Thanks for the reply. I understand that testing once in global is not accurate, it’s just that the difference is too large to be normal. Here the new result following your code ac = Array{Float64}(undef, 2^20) ag = cu(ac) @btime randn!(ac) @btime CuArrays.@sync randn!(ag) 6.788 ms (0 allocations: 0 bytes) 7.626 s (5242883 allocations: 288.00 MiB) So the allocations are clearly the problem, but I can’t really figure out the reason. Even with rand there are some extra allocations @…

but as you noted bits are bytes anyways, so maybe you can just use a `if < 0.5` or something.

---

_[View the full topic](https://discourse.julialang.org/t/random-numbers-in-0-f0-1-f0/30926)._
