OK, I see your point. The higher resolution you have in the random number, the less quantization error. The example in my article is based on a resolution of 32 bits in x. If you use a double with a resolution of 52 (or 53) bits and r < 2^32 then you will have a very small quantization error, probably too small to be significant. Alternatively, you may use a 64 bit x 64 bit -> 128 bit unsigned integer multiplication of x and r, and take the high part of the result. If you are running in 64 bit mode, use this method:
stackoverflow.com/questions/1541426/computing-high-64-bits-of-a-64x64-int-product-in-c In 32-bit mode use this method:
blogs.msdn.com/b/oldnewthing/archive/2014/12/08/10578956.aspx |