diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-12-22 00:50:30 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-12-22 00:50:30 -0500 |
| commit | d917815d8111b98dc237cbe2c723fa63018e02b1 (patch) | |
| tree | ce12771a86b2412ee9692ca73d3ca49abe5da3ce /std/math/log2.zig | |
| parent | 8bc523219c66427951e5339550502871547f2138 (diff) | |
| download | zig-d917815d8111b98dc237cbe2c723fa63018e02b1.tar.gz zig-d917815d8111b98dc237cbe2c723fa63018e02b1.zip | |
explicitly return from blocks
instead of last statement being expression value
closes #629
Diffstat (limited to 'std/math/log2.zig')
| -rw-r--r-- | std/math/log2.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/std/math/log2.zig b/std/math/log2.zig index 2199d6bfa1..1b38a9ecee 100644 --- a/std/math/log2.zig +++ b/std/math/log2.zig @@ -14,7 +14,7 @@ pub fn log2(x: var) -> @typeOf(x) { const T = @typeOf(x); switch (@typeId(T)) { TypeId.FloatLiteral => { - return @typeOf(1.0)(log2_64(x)) + return @typeOf(1.0)(log2_64(x)); }, TypeId.Float => { return switch (T) { @@ -26,7 +26,7 @@ pub fn log2(x: var) -> @typeOf(x) { TypeId.IntLiteral => comptime { var result = 0; var x_shifted = x; - while ({x_shifted >>= 1; x_shifted != 0}) : (result += 1) {} + while (b: {x_shifted >>= 1; break :b x_shifted != 0;}) : (result += 1) {} return result; }, TypeId.Int => { @@ -94,7 +94,7 @@ pub fn log2_32(x_: f32) -> f32 { u &= 0xFFFFF000; hi = @bitCast(f32, u); const lo = f - hi - hfsq + s * (hfsq + R); - (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + f32(k) + return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + f32(k); } pub fn log2_64(x_: f64) -> f64 { @@ -165,7 +165,7 @@ pub fn log2_64(x_: f64) -> f64 { val_lo += (y - ww) + val_hi; val_hi = ww; - val_lo + val_hi + return val_lo + val_hi; } test "math.log2" { |
