aboutsummaryrefslogtreecommitdiff
path: root/std/math/log2.zig
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2019-05-01 18:15:57 +1200
committerMarc Tiehuis <marctiehuis@gmail.com>2019-05-01 18:37:46 +1200
commit89d71a960b0f90335fded84a449a84806bb6f661 (patch)
treeefbb720dbdd17ad782233c958f11d2f584d662c4 /std/math/log2.zig
parentf94964cd057ace39caa05c10d9626ac6a4beb23b (diff)
downloadzig-89d71a960b0f90335fded84a449a84806bb6f661.tar.gz
zig-89d71a960b0f90335fded84a449a84806bb6f661.zip
std.math: Add documentation for all functions and algorithm sources
Diffstat (limited to 'std/math/log2.zig')
-rw-r--r--std/math/log2.zig16
1 files changed, 11 insertions, 5 deletions
diff --git a/std/math/log2.zig b/std/math/log2.zig
index e2dbf4105a..88450a7ffd 100644
--- a/std/math/log2.zig
+++ b/std/math/log2.zig
@@ -1,9 +1,8 @@
-// Special Cases:
+// Ported from musl, which is licensed under the MIT license:
+// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
//
-// - log2(+inf) = +inf
-// - log2(0) = -inf
-// - log2(x) = nan if x < 0
-// - log2(nan) = nan
+// https://git.musl-libc.org/cgit/musl/tree/src/math/log2f.c
+// https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c
const std = @import("../std.zig");
const math = std.math;
@@ -12,6 +11,13 @@ const builtin = @import("builtin");
const TypeId = builtin.TypeId;
const maxInt = std.math.maxInt;
+/// Returns the base-2 logarithm of x.
+///
+/// Special Cases:
+/// - log2(+inf) = +inf
+/// - log2(0) = -inf
+/// - log2(x) = nan if x < 0
+/// - log2(nan) = nan
pub fn log2(x: var) @typeOf(x) {
const T = @typeOf(x);
switch (@typeId(T)) {