Skip to content

Commit dd88f5b

Browse files
xDivisionByZeroxST-DDT
authored andcommitted
refactor: swap values when min is bigger max
1 parent 42c3af7 commit dd88f5b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mersenne.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export class Mersenne {
3030
*/
3131
rand(max = 32768, min = 0): number {
3232
if (min > max) {
33-
throw new Error('Invalid input: "min" cannot be bigger than "max".');
33+
const temp = min;
34+
min = max;
35+
max = temp;
3436
}
3537

3638
return Math.floor(this.gen.genrandReal2() * (max - min) + min);

0 commit comments

Comments
 (0)