aboutsummaryrefslogtreecommitdiff
path: root/std/math/fma.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-12-22 00:50:30 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-12-22 00:50:30 -0500
commitd917815d8111b98dc237cbe2c723fa63018e02b1 (patch)
treece12771a86b2412ee9692ca73d3ca49abe5da3ce /std/math/fma.zig
parent8bc523219c66427951e5339550502871547f2138 (diff)
downloadzig-d917815d8111b98dc237cbe2c723fa63018e02b1.tar.gz
zig-d917815d8111b98dc237cbe2c723fa63018e02b1.zip
explicitly return from blocks
instead of last statement being expression value closes #629
Diffstat (limited to 'std/math/fma.zig')
-rw-r--r--std/math/fma.zig20
1 files changed, 10 insertions, 10 deletions
diff --git a/std/math/fma.zig b/std/math/fma.zig
index 8dbbc39ed0..c870dfd293 100644
--- a/std/math/fma.zig
+++ b/std/math/fma.zig
@@ -2,11 +2,11 @@ const math = @import("index.zig");
const assert = @import("../debug.zig").assert;
pub fn fma(comptime T: type, x: T, y: T, z: T) -> T {
- switch (T) {
+ return switch (T) {
f32 => @inlineCall(fma32, x, y, z),
f64 => @inlineCall(fma64, x, y ,z),
else => @compileError("fma not implemented for " ++ @typeName(T)),
- }
+ };
}
fn fma32(x: f32, y: f32, z: f32) -> f32 {
@@ -16,10 +16,10 @@ fn fma32(x: f32, y: f32, z: f32) -> f32 {
const e = (u >> 52) & 0x7FF;
if ((u & 0x1FFFFFFF) != 0x10000000 or e == 0x7FF or xy_z - xy == z) {
- f32(xy_z)
+ return f32(xy_z);
} else {
// TODO: Handle inexact case with double-rounding
- f32(xy_z)
+ return f32(xy_z);
}
}
@@ -64,9 +64,9 @@ fn fma64(x: f64, y: f64, z: f64) -> f64 {
const adj = add_adjusted(r.lo, xy.lo);
if (spread + math.ilogb(r.hi) > -1023) {
- math.scalbn(r.hi + adj, spread)
+ return math.scalbn(r.hi + adj, spread);
} else {
- add_and_denorm(r.hi, adj, spread)
+ return add_and_denorm(r.hi, adj, spread);
}
}
@@ -77,7 +77,7 @@ fn dd_add(a: f64, b: f64) -> dd {
ret.hi = a + b;
const s = ret.hi - a;
ret.lo = (a - (ret.hi - s)) + (b - s);
- ret
+ return ret;
}
fn dd_mul(a: f64, b: f64) -> dd {
@@ -99,7 +99,7 @@ fn dd_mul(a: f64, b: f64) -> dd {
ret.hi = p + q;
ret.lo = p - ret.hi + q + la * lb;
- ret
+ return ret;
}
fn add_adjusted(a: f64, b: f64) -> f64 {
@@ -113,7 +113,7 @@ fn add_adjusted(a: f64, b: f64) -> f64 {
sum.hi = @bitCast(f64, uhii);
}
}
- sum.hi
+ return sum.hi;
}
fn add_and_denorm(a: f64, b: f64, scale: i32) -> f64 {
@@ -127,7 +127,7 @@ fn add_and_denorm(a: f64, b: f64, scale: i32) -> f64 {
sum.hi = @bitCast(f64, uhii);
}
}
- math.scalbn(sum.hi, scale)
+ return math.scalbn(sum.hi, scale);
}
test "math.fma" {