authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-18 14:41:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-18 14:41:33-04:00
log3817420d42dd07fa9a48e1a7521cb520539b6f64
tree8dc67b56e3d40b5e55ded9aa89025871218fb3d5
parentca38b188798cda8377c56cdbd0858df08f8c503f

ziggurat uses `@truncate` instead of `& 0xff`

This makes it work on 32-bit targets. closes #2939

1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/rand/ziggurat.zig+1-1
...@@ -17,7 +17,7 @@ pub fn next_f64(random: *Random, comptime tables: ZigTable) f64 {...@@ -17,7 +17,7 @@ pub fn next_f64(random: *Random, comptime tables: ZigTable) f64 {
17 // We manually construct a float from parts as we can avoid an extra random lookup here by17 // We manually construct a float from parts as we can avoid an extra random lookup here by
18 // using the unused exponent for the lookup table entry.18 // using the unused exponent for the lookup table entry.
19 const bits = random.int(u64);19 const bits = random.int(u64);
20 const i = @as(usize, bits & 0xff);20 const i = @as(usize, @truncate(u8, bits));
2121
22 const u = blk: {22 const u = blk: {
23 if (tables.is_symmetric) {23 if (tables.is_symmetric) {