From aa0daea5415dd2a20e4d7c2fd047b7bcee6c9ea4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 7 Nov 2019 18:52:09 -0500 Subject: update more of the std lib to use `@as` --- lib/std/rand.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/std/rand.zig') diff --git a/lib/std/rand.zig b/lib/std/rand.zig index 2cd1583f63..1fea0526ed 100644 --- a/lib/std/rand.zig +++ b/lib/std/rand.zig @@ -93,13 +93,13 @@ pub const Random = struct { // http://www.pcg-random.org/posts/bounded-rands.html // "Lemire's (with an extra tweak from me)" var x: Small = r.int(Small); - var m: Large = Large(x) * Large(less_than); + var m: Large = @as(Large, x) * @as(Large, less_than); var l: Small = @truncate(Small, m); if (l < less_than) { // TODO: workaround for https://github.com/ziglang/zig/issues/1770 // should be: // var t: Small = -%less_than; - var t: Small = @bitCast(Small, -%@bitCast(@IntType(true, Small.bit_count), Small(less_than))); + var t: Small = @bitCast(Small, -%@bitCast(@IntType(true, Small.bit_count), @as(Small, less_than))); if (t >= less_than) { t -= less_than; @@ -109,7 +109,7 @@ pub const Random = struct { } while (l < t) { x = r.int(Small); - m = Large(x) * Large(less_than); + m = @as(Large, x) * @as(Large, less_than); l = @truncate(Small, m); } } @@ -286,7 +286,7 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html // "Integer Multiplication (Biased)" - var m: T2 = T2(random_int) * T2(less_than); + var m: T2 = @as(T2, random_int) * @as(T2, less_than); return @intCast(T, m >> T.bit_count); } -- cgit v1.2.3