Skip to content

Commit 5302839

Browse files
author
kristopher tate
committed
std.rand: builtin @{min,max}Value to std.math.{min,max}Value;
1 parent 50e7de8 commit 5302839

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

std/rand/index.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub const Random = struct {
3939
return r.int(u1) != 0;
4040
}
4141

42-
/// Returns a random int `i` such that `0 <= i <= @maxValue(T)`.
42+
/// Returns a random int `i` such that `0 <= i <= std.math.maxInt(T)`.
4343
/// `i` is evenly distributed.
4444
pub fn int(r: *Random, comptime T: type) T {
4545
const UnsignedT = @IntType(false, T.bit_count);
@@ -69,14 +69,14 @@ pub const Random = struct {
6969
assert(T.is_signed == false);
7070
assert(0 < less_than);
7171

72-
const last_group_size_minus_one: T = @maxValue(T) % less_than;
72+
const last_group_size_minus_one: T = std.math.maxInt(T) % less_than;
7373
if (last_group_size_minus_one == less_than - 1) {
7474
// less_than is a power of two.
7575
assert(math.floorPowerOfTwo(T, less_than) == less_than);
76-
// There is no retry zone. The optimal retry_zone_start would be @maxValue(T) + 1.
76+
// There is no retry zone. The optimal retry_zone_start would be std.math.maxInt(T) + 1.
7777
return r.int(T) % less_than;
7878
}
79-
const retry_zone_start = @maxValue(T) - last_group_size_minus_one;
79+
const retry_zone_start = std.math.maxInt(T) - last_group_size_minus_one;
8080

8181
while (true) {
8282
const rand_val = r.int(T);
@@ -91,7 +91,7 @@ pub const Random = struct {
9191
/// for commentary on the runtime of this function.
9292
pub fn uintAtMost(r: *Random, comptime T: type, at_most: T) T {
9393
assert(T.is_signed == false);
94-
if (at_most == @maxValue(T)) {
94+
if (at_most == std.math.maxInt(T)) {
9595
// have the full range
9696
return r.int(T);
9797
}

0 commit comments

Comments
 (0)