diff --git a/hwe/ts/util/RandUtil.ts b/hwe/ts/util/RandUtil.ts index 8a778fd4..ef3d4908 100644 --- a/hwe/ts/util/RandUtil.ts +++ b/hwe/ts/util/RandUtil.ts @@ -35,6 +35,9 @@ export class RandUtil { if (prob === 0.5){ return this.nextBit(); } + if (prob <= 0){ + return false; + } return this.nextFloat1() < prob; } diff --git a/src/sammo/RandUtil.php b/src/sammo/RandUtil.php index 962fd5c4..591214d2 100644 --- a/src/sammo/RandUtil.php +++ b/src/sammo/RandUtil.php @@ -42,9 +42,12 @@ class RandUtil if ($prob >= 1) { return true; } - if($prob === 0.5){ + if ($prob === 0.5){ return $this->nextBit(); } + if ($prob <= 0){ + return false; + } return $this->nextFloat1() < $prob; }