# Output distribution of rand(Float32) and rand(Float64), thread 2

**URL:** <https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184>\
**Category:** Internals & Design\
**Tags:** float, random\
**Created:** [October 19, 2023, 1:10pm UTC](https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184 "2023-10-19T13:10:07Z")\
**Posts on this page:** 1\
**Showing post:** 38

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [October 20, 2023, 2:06pm UTC](https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184/38 "2023-10-20T14:06:16Z")

</div>

> [@foobar\_lv2](#):
>
> Does this code scream NOPE NOPE NOPE to you @Sukera ?

Considering the current generation scheme more or less has

```julia
julia> eps(nextfloat(1.0f0))
1.1920929f-7

julia> eps(prevfloat(2.0f0))
1.1920929f-7

```

as its accuracy, yes. I agree though that requiring to know this is neither ergonomic nor good for a user 🤔 On the other hand, one could also argue that this is inevitable depending on which value you pick; don’t you get the same “overweighing” on the other end of the interval, no matter whether this is fixed for small numbers? After all, the “proper” bin has a higher precision than the interval we currently generate too:

```julia
julia> eps(prevfloat(1f0))
5.9604645f-8

```

Either way, if this is changed, it should definitely be clarified that `rand()` samples from the representable floating point values in the interval `[0, 1)`, and not from the real number line.

---

_[View the full topic](https://discourse.julialang.org/t/output-distribution-of-rand-float32-and-rand-float64-thread-2/105184)._
