Quoting Marvin Renich (2019-02-26 07:11:47)
> * Louki Sumirniy <louki.sumirniy.stal...@gmail.com> [190226 06:22]:
> > Assuming there is bytes in the system's entropy pool, you can also skip the
> > scrambling step, though I don't know what overhead consuming these bytes
> > entails compared to a standard PRNG. Then the biggest part of it is making
> > the raw bytes into float. I'm not sure - could you take 4 random bytes,
> > grab the unsafe pointer and cast back to float32?
>
> No, you could get one of many NANs.  However, converting uint16 to
> float32 (or float64) should be very efficient, then you have one
> floating point divide by constant to get the desired range.

See my comment elsewhere in the thread from yesterday; you could just
hard code the sign bit and the exponent (an exponent of -24 will make
sure you get the right range), and then fill in the fractional part of
the float with random bits.

-Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to