(wrong string) ée

From: <git_AT_suckless.org>
Date: Thu, 2 Jun 2016 12:56:55 +0200 (CEST)

commit d1771305d6b1a548544119ce953c9bb758c6b77a
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Thu Jun 2 12:42:12 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Thu Jun 2 12:42:12 2016 +0200

    On bit test
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/doc/bit-operations.tex b/doc/bit-operations.tex
index c3fbe4a..8bf3d36 100644
--- a/doc/bit-operations.tex
+++ b/doc/bit-operations.tex
_AT_@ -209,7 +209,7 @@ divide-and-conquer algorithms.
 The function
- zbset(z_t r, z_t a, size_t bit, int mode);
+ void zbset(z_t r, z_t a, size_t bit, int mode);
_AT_@ -233,7 +233,40 @@ $mode < 0$ ($-1$): flip
 \section{Bit test}
 \label{sec:Bit test}
-TODO % zbtest
+libzahl provides a function for testing whether a bit
+in a big integer is set:
+ int zbtest(z_t a, size_t bit);
+it will return 1 if the bit with the index {\tt bit}
+is set in {\tt a}, counting from the least significant
+bit, starting at zero. 0 is returned otherwise. The
+sign of {\tt a} is ignored.
+We can think of this like so: consider
+$$ \lvert a \rvert = \sum_{i = 0}^\infty k_i 2^i,~ k_i \in \{0, 1\}, $$
+{\tt zbtest(a, b)} returns $k_b$. Equivalently, we can think
+that {\tt zbtest(a, b)} return whether $b \in B$ where $B$
+is defined by
+$$ \lvert a \rvert = \sum_{b \in B} 2^b,~ B \subset \textbf{Z}_+, $$
+or as right-shifting $a$ by $b$ bits and returning whether the
+least significant bit is set.
+{\tt zbtest} always returns 1 or 0, but for good code quality, you
+should avoid testing against 1, rather you should test whether the
+value is a truth-value or a falsehood-value. However, there is
+nothing wrong with depending on the value being restricted to being
+either 1 or 0 if you want to sum up returned values or otherwise
+use them in new values.
Received on Thu Jun 02 2016 - 12:56:55 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 02 2016 - 13:00:28 CEST