aboutsummaryrefslogtreecommitdiff
path: root/std/math/nan.zig
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2017-06-16 20:26:10 +1200
committerMarc Tiehuis <marctiehuis@gmail.com>2017-06-16 20:32:31 +1200
commit4c16f9a3c35b23b9917f2a27b91ba8cd20e6fd82 (patch)
tree778f0f06734f7dc17e9269ee1cf5b513f7b504c0 /std/math/nan.zig
parent865b53f2860405a718262abf9a794d2bf9529dbc (diff)
downloadzig-4c16f9a3c35b23b9917f2a27b91ba8cd20e6fd82.tar.gz
zig-4c16f9a3c35b23b9917f2a27b91ba8cd20e6fd82.zip
Add math library
This covers the majority of the functions as covered by the C99 specification for a math library. Code is adapted primarily from musl libc, with the pow and standard trigonometric functions adapted from the Go stdlib. Changes: - Remove assert expose in index and import as needed. - Add float log function and merge with existing base 2 integer implementation. See https://github.com/tiehuis/zig-fmath. See #374.
Diffstat (limited to 'std/math/nan.zig')
-rw-r--r--std/math/nan.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/std/math/nan.zig b/std/math/nan.zig
new file mode 100644
index 0000000000..bd079026a5
--- /dev/null
+++ b/std/math/nan.zig
@@ -0,0 +1,9 @@
+const math = @import("index.zig");
+
+pub fn nan(comptime T: type) -> T {
+ switch (T) {
+ f32 => @bitCast(f32, math.nan_u32),
+ f64 => @bitCast(f64, math.nan_u64),
+ else => @compileError("nan not implemented for " ++ @typeName(T)),
+ }
+}