random_compat icon indicating copy to clipboard operation
random_compat copied to clipboard

Floating-point interval should be half-open

Open Metabolix opened this issue 12 years ago • 0 comments

Your library apparently generates floats in the closed interval [0,1]. Many other languages (e.g. Java, JS, C++11, Perl, Python, Ruby) use the half-open interval [0,1) instead. Have you considered this?

I think it would be better to use the half-open interval both because everybody else does it and because it's more useful: most people don't need the 1.0 anyway, and if they do, they usually expect it to occur with a probability greater than 1/(MAX_INT+1).

Metabolix avatar Nov 06 '13 20:11 Metabolix