1

I've observed that a sample generated from a std::uniform_real_distribution<float> can be equal to 1 (compiled using Visual Studio 2022).

This is in contrast to the description in standard stating that it should be a uniform draw from [0, 1); hence 1 should be excluded.

Is this cause I'm using float instead of double? Or is this a bug in the Visual Studio 2022 implementation?

And what can I do now? It is important for me that the draw is from [0, 1) and not from [0, 1]. My current solution is to replace the draw u by u - std::floor(u).

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
  • @PeterO. Thank you for the link; it is really interesting. However, I've now tested it with `double` instead of `float` and it still happens that the outcome can be `1`. – 0xbadf00d Sep 02 '23 at 14:12

0 Answers0