Skip to content

Commit 3e94347

Browse files
tgschultzandrewrk
authored andcommittedJun 27, 2018
Fix up some std.rand syntax #1161 (#1162)
* Fix old syntax in rand Ziggurat somehow did not get updated to latest syntax * Fix broken float casts f32 float casts somehow not updated to latest syntax
·
0.15.20.3.0
1 parent 1b4bae6 commit 3e94347

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎std/rand/index.zig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub const Random = struct {
116116
pub fn floatNorm(r: *Random, comptime T: type) T {
117117
const value = ziggurat.next_f64(r, ziggurat.NormDist);
118118
switch (T) {
119-
f32 => return f32(value),
119+
f32 => return @floatCast(f32, value),
120120
f64 => return value,
121121
else => @compileError("unknown floating point type"),
122122
}
@@ -128,7 +128,7 @@ pub const Random = struct {
128128
pub fn floatExp(r: *Random, comptime T: type) T {
129129
const value = ziggurat.next_f64(r, ziggurat.ExpDist);
130130
switch (T) {
131-
f32 => return f32(value),
131+
f32 => return @floatCast(f32, value),
132132
f64 => return value,
133133
else => @compileError("unknown floating point type"),
134134
}

‎std/rand/ziggurat.zig‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ fn ZigTableGen(
8484

8585
for (tables.x[2..256]) |*entry, i| {
8686
const last = tables.x[2 + i - 1];
87-
*entry = f_inv(v / last + f(last));
87+
entry.* = f_inv(v / last + f(last));
8888
}
8989
tables.x[256] = 0;
9090

9191
for (tables.f[0..]) |*entry, i| {
92-
*entry = f(tables.x[i]);
92+
entry.* = f(tables.x[i]);
9393
}
9494

9595
return tables;
@@ -160,3 +160,7 @@ test "ziggurant exp dist sanity" {
160160
_ = prng.random.floatExp(f64);
161161
}
162162
}
163+
164+
test "ziggurat table gen" {
165+
const table = NormDist;
166+
}

0 commit comments

Comments
 (0)
Please sign in to comment.