(wrong string) ée

From: <git_AT_suckless.org>
Date: Wed, 2 Mar 2016 10:27:15 +0100 (CET)

commit fe15c7e5b115cae4717f5481e7962cf376066387
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Wed Mar 2 08:57:46 2016 +0100
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Wed Mar 2 08:57:50 2016 +0100

    Why zbits returns 1 for 0
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/man/zbits.3 b/man/zbits.3
index 3dea6d9..191a87c 100644
--- a/man/zbits.3
+++ b/man/zbits.3
_AT_@ -25,6 +25,14 @@ absolute value of
 \(em or 1 if
 .I a
 is zero.
+.SH RATIONALE
+.B zbits
+returns 1 rather than 0 if
+.B a
+is zero, this is to avoid off-by-one errors
+and it is the number of digits requires to
+write the number in binary. You will see this
+in corresponding functions in other libraries.
 .SH SEE ALSO
 .BR zlsb (3),
 .BR zzero (3)
diff --git a/src/zbits.c b/src/zbits.c
index 8ada62f..f0c15c9 100644
--- a/src/zbits.c
+++ b/src/zbits.c
_AT_@ -7,9 +7,8 @@ zbits(z_t a)
 {
         size_t i;
         zahl_char_t x;
- if (zzero(a)) {
- return 1;
- }
+ if (zzero(a))
+ return 1; /* Deliver us from evil! */
         for (i = a->used - 1;; i--) {
                 x = a->chars[i];
                 if (x) {
Received on Wed Mar 02 2016 - 10:27:15 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 02 2016 - 10:36:17 CET