about summary refs log tree commit diff
path: root/src/libstd/num/i8.rs
diff options
context:
space:
mode:
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-02-17 10:12:10 +1100
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>2014-02-17 13:55:06 +1100
commit79f52cf9ba20c36860bee8f775498a0880189ac1 (patch)
tree34d366700d281c19ec5b2b2231818b4ad720165e /src/libstd/num/i8.rs
parent0ba6d4885fc71ca7156e1fe689edb939e1d9d418 (diff)
downloadrust-79f52cf9ba20c36860bee8f775498a0880189ac1.tar.gz
rust-79f52cf9ba20c36860bee8f775498a0880189ac1.zip
Rename Bitwise::population_count to Bitwise::count_ones and add Bitwise::count_zeros
These are inspired by the [functions in the Julia standard library](http://docs.julialang.org/en/release-0.2/stdlib/base/#Base.count_ones).
Diffstat (limited to 'src/libstd/num/i8.rs')
-rw-r--r--src/libstd/num/i8.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs
index 66162ce3502..e0e549b731a 100644
--- a/src/libstd/num/i8.rs
+++ b/src/libstd/num/i8.rs
@@ -25,15 +25,17 @@ use unstable::intrinsics;
 int_module!(i8, 8)
 
 impl Bitwise for i8 {
-    /// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
+    /// Returns the number of ones in the binary representation of the number.
     #[inline]
-    fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
+    fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
 
-    /// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
+    /// Returns the number of leading zeros in the in the binary representation
+    /// of the number.
     #[inline]
     fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
 
-    /// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
+    /// Returns the number of trailing zeros in the in the binary representation
+    /// of the number.
     #[inline]
     fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
 }