and sorry if this is a duplicate of some sort, my poor technical vocabulary doesn't get me very far with google.
I am trying to implement some well-known PRNG algorithms. For the time, the algorithm in themselves do their job very well (generating 16/32/64/128 random bits). I am now trying to create a uniform distribution function, that, taking as input a 16/32/64/128 bit integer spits a IEEE compliant binary2, binary4 or binary8 (the function doesn't have to handle all of them at once, but by able to somewhat template for the other floating point types.
As quoted in the title of the question, the output shall be between -1.0 and 1.0 . A naive implementaion would be to take a byte of the integers, and affect it to the exponent, while leaving the rest to the mantissa (padding with 0s if there's not enough bits), but how to handle denormals (the code is performance critical, and the target is reluctant with un-uniform data-based condition). How to handle these then ?.
And while that may be asking two questions at once, how to do the same for a normal distribution ?
Any help or guidance is appreciated. Thanks in advance