Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • \$\begingroup\$ Not valid because random() has finite precision, hence not all numbers could be generated, unfortunately. \$\endgroup\$ Commented Mar 4, 2022 at 3:08
  • 4
    \$\begingroup\$ @Real OP explicitly states infinite precision may be assumed. \$\endgroup\$ Commented Mar 4, 2022 at 6:35
  • \$\begingroup\$ I believe you can use random() instead of (1-random()) \$\endgroup\$ Commented Jul 22, 2023 at 8:14
  • \$\begingroup\$ @Iamkindofalanguagedev random() can generate 0.0, which would cause a division by zero, in this code. \$\endgroup\$ Commented Jul 22, 2023 at 9:02
  • \$\begingroup\$ @solid.py Can’t it also generate 1.0? \$\endgroup\$ Commented Jul 22, 2023 at 9:05