https://github.com/colgreen/Redzen/blob/master/Redzen/Random...
There's an explanation in the comments, and a link to the original fuller explanation and source, here:
https://mumble.net/~campbell/tmp/random_real.c
I.e. I'm pretty sure your approach gives a non uniform distribution, but happy to discuss in more detail if you want.