Skip to content

Commit

Permalink
fix: randi now returns 0 or 1 instead of 0 when no args (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
imaginarny authored Oct 29, 2024
1 parent cc1a866 commit 3672710
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/math/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,9 +1132,8 @@ export function rand<T = number>(...args: [] | [T] | [T, T]) {
return defRNG.genAny(...args);
}

// TODO: randi() to return 0 / 1?
export function randi(...args: [] | [number] | [number, number]) {
return Math.floor(rand(...args));
return Math.floor(rand(...(args.length > 0 ? args : [2])));
}

export function chance(p: number): boolean {
Expand Down

0 comments on commit 3672710

Please sign in to comment.