[hackers] [libzahl] Fix errors in the manual (most of them found by Ivan Zuboff) || Mattias Andrée

2016-11-29 Thread git
commit 781e9d05388539d989e3578ebc7f8a7cd038aeb0
Author: Mattias Andrée 
AuthorDate: Tue Nov 29 23:55:29 2016 +0100
Commit: Mattias Andrée 
CommitDate: Tue Nov 29 23:55:29 2016 +0100

Fix errors in the manual (most of them found by Ivan Zuboff)

Signed-off-by: Mattias Andrée 

diff --git a/doc/arithmetic.tex b/doc/arithmetic.tex
index 2e15a75..2c5a9d3 100644
--- a/doc/arithmetic.tex
+++ b/doc/arithmetic.tex
@@ -69,7 +69,7 @@ instruction specifically for performing
 addition with ripple-carry over multiple words,
 adds twos numbers plus the carry from the
 last addition. libzahl uses assembly to
-implement this efficiently. If however, an
+implement this efficiently. If, however, an
 assembly implementation is not available for
 the on which machine it is running, libzahl
 implements ripple-carry less efficiently
@@ -80,8 +80,8 @@ the compiler is known to support this
 extension, it is implemented using inefficient
 pure C code. This last resort manually
 predicts whether an addition will overflow;
-this could be made more efficent, but never
-using the highest bit, in each character,
+this could be made more efficient, by never
+using the highest bit in each character,
 except to detect overflow. This optimisation
 is however not implemented because it is
 not deemed important enough and would
@@ -100,9 +100,9 @@ in-place operation:
 \noindent
 Use this whenever possible, it will improve
 your performance, as it will involve less
-CPU instructions for each character-addition
+CPU instructions for each character addition
 and it may be possible to eliminate some
-character-additions.
+character additions.
 
 
 \newpage
@@ -138,7 +138,7 @@ These function \emph{do not} allow {\tt NULL}
 for the output parameters: {\tt quotient} and
 {\tt remainder}. The quotient and remainder are
 calculated simultaneously and indivisibly, hence
-{\tt zdivmod} is provided to calculated both, if
+{\tt zdivmod} is provided to calculated both; if
 you are only interested in the quotient or only
 interested in the remainder, use {\tt zdiv} or
 {\tt zmod}, respectively.
@@ -146,14 +146,14 @@ interested in the remainder, use {\tt zdiv} or
 These functions calculate a truncated quotient.
 That is, the result is rounded towards zero. This
 means for example that if the quotient is in
-$(-1,~1)$, {\tt quotient} gets 0. That that, this
+$(-1,~1)$, {\tt quotient} gets 0. That is, this % TODO try to clarify
 would not be the case for one of the sides of zero.
 For example, if the quotient would have been
 floored, negative quotients would have been rounded
 away from zero. libzahl only provides truncated
-division,
+division.
 
-The remain is defined such that $n = qd + r$ after
+The remainder is defined such that $n = qd + r$ after
 calling {\tt zdivmod(q, r, n, d)}. There is no
 difference in the remainer between {\tt zdivmod}
 and {\tt zmod}. The sign of {\tt d} has no affect
@@ -188,7 +188,7 @@ lend you a hand.
 
 % Floored division
 \begin{alltt}
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_floor(z_t q, z_t r, z_t n, z_t d)
\{
zdivmod(q, r, n, d);
@@ -199,7 +199,7 @@ lend you a hand.
 
 % Ceiled division
 \begin{alltt}
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_ceiling(z_t q, z_t r, z_t n, z_t d)
\{
zdivmod(q, r, n, d);
@@ -214,7 +214,7 @@ lend you a hand.
 %commercial rounding
 \begin{alltt}
/* \textrm{This is how we normally round numbers.} */
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_half_from_zero(z_t q, z_t r, z_t n, z_t d)
\{
zdivmod(q, r, n, d);
@@ -237,7 +237,7 @@ not award you a face-slap. % Had positive punishment
 % This rounding method is also called:
 % round half away from infinity
 \begin{alltt}
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_half_to_zero(z_t q, z_t r, z_t n, z_t d)
\{
zdivmod(q, r, n, d);
@@ -254,7 +254,7 @@ not award you a face-slap. % Had positive punishment
 % This rounding method is also called:
 % round half towards positive infinity
 \begin{alltt}
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_half_up(z_t q, z_t r, z_t n, z_t d)
\{
int cmp;
@@ -272,7 +272,7 @@ not award you a face-slap. % Had positive punishment
 % This rounding method is also called:
 % round half towards negative infinity
 \begin{alltt}
-   void \textcolor{c}{/* \textrm{All arguments most be unique.} */}
+   void \textcolor{c}{/* \textrm{All arguments must be unique.} */}
divmod_half_down(z_t q, z_t r, z_t n, z_

[hackers] [libzahl] Fix errors in the manual (most of them found by Ivan Zuboff) || Mattias Andrée

2016-11-30 Thread git
commit aeb5e44a98cb4158528206c079654357b1c75b16
Author: Mattias Andrée 
AuthorDate: Wed Nov 30 10:15:59 2016 +0100
Commit: Mattias Andrée 
CommitDate: Wed Nov 30 10:15:59 2016 +0100

Fix errors in the manual (most of them found by Ivan Zuboff)

Signed-off-by: Mattias Andrée 

diff --git a/doc/exercises.tex b/doc/exercises.tex
index 3a9df19..9a18b99 100644
--- a/doc/exercises.tex
+++ b/doc/exercises.tex
@@ -596,7 +596,7 @@ ptest_llt(z_t n)
 
 $M_n$ is composite if $n$ is composite, therefore,
 if you do not expect prime-only values on $n$, the
-performance can be improve by using some other
+performance can be improved by using some other
 primality test (or this same test if $n$ is a
 Mersenne number) to first check that $n$ is prime.
 
diff --git a/doc/miscellaneous.tex b/doc/miscellaneous.tex
index 8750595..420d6a7 100644
--- a/doc/miscellaneous.tex
+++ b/doc/miscellaneous.tex
@@ -101,7 +101,7 @@ sum of a set of numbers.
 Another form of assignment available in libzahl is
 copy-assignment. This done using {\tt zset}. As
 easily observable, {\tt zset} is named like
-{\tt zseti}, {\tt zsetu}, and {\tt zsetu}, but
+{\tt zseti}, {\tt zsetu}, and {\tt zsets}, but
 without the input-type suffix. The lack of a
 input-type suffix means that the input type is
 {\tt z\_t}. {\tt zset} copies value of second
diff --git a/doc/not-implemented.tex b/doc/not-implemented.tex
index 59b3efb..9688189 100644
--- a/doc/not-implemented.tex
+++ b/doc/not-implemented.tex
@@ -3,25 +3,25 @@
 
 In this chapter we maintain a list of
 features we have chosen not to implement,
-but would fit into libzahl had we not have
+but would fit into libzahl, had we not have
 our priorities straight. Functions listed
 herein will only be implemented if it is
 shown that it would be overwhelmingly
 advantageous. For each feature, a sample
 implementation or a mathematical expression
-on which you can base your implemention
-is included. The sample implementations create
-temporary integer references, this is to
-simplify the examples. You should try to
-use dedicated variables; in case of recursion,
-a robust program should store temporary
-variables on a stack, so they can be
-clean up if something happens.
-
-Research problems, like prime-factorisation
-and discrete logarithms do not fit in the
-scope of bignum libraries. % Unless they are extraordinarily bloated with 
vague mission-scope, like systemd.
-And therefore do not fit into libzahl,
+on which you can base your implementation is
+included. The sample implementations create
+temporary integer references to simplify the
+examples. You should try to use dedicated
+variables; in case of recursion, a robust
+program should store temporary variables on
+a stack, so they can be cleaned up if
+something happens.
+
+Research problems, like prime factorisation
+and discrete logarithms, do not fit in the
+scope of bignum libraries % Unless they are extraordinarily bloated with vague 
mission-scope, like systemd.
+and therefore do not fit into libzahl,
 and will not be included in this chapter.
 Operators and functions that grow so
 ridiculously fast that a tiny lookup table
@@ -330,7 +330,7 @@ method can be derived from the observation
 \vspace{1em}
 
 \noindent
-The resulting algorithm can be expressed
+The resulting algorithm can be expressed as
 
 \begin{alltt}
void
@@ -690,10 +690,10 @@ in an integer, counting the sign bit:
 \end{alltt}
 
 \noindent
-It requires a compiler extension, if missing,
-there are other ways to computer the population
-count for a word: manually bit-by-bit, or with
-a fully unrolled
+It requires a compiler extension; if it's not
+available, there are other ways to computer the
+population count for a word: manually bit-by-bit,
+or with a fully unrolled
 
 \begin{alltt}
int s;
@@ -706,7 +706,7 @@ a fully unrolled
 \label{sec:Hamming distance}
 
 A simple way to compute the Hamming distance,
-the number of differing bits, between two
+the number of differing bits between two
 numbers is with the function
 
 \begin{alltt}
@@ -767,13 +767,13 @@ side-effects.
 \label{sec:Reference duplication}
 
 This could be useful for creating duplicates
-with modified sign. But only if neither
+with modified sign, but only if neither
 {\tt r} nor {\tt a} will be modified whilst
 both are in use. Because it is unsafe,
 fairly simple to create an implementation
 with acceptable performance — {\tt *r = *a},
 — and probably seldom useful, this has not
-be implemented.
+been implemented.
 
 \begin{alltt}
void
diff --git a/doc/number-theory.tex b/doc/number-theory.tex
index 10c485b..b4c2ece 100644
--- a/doc/number-theory.tex
+++ b/doc/number-theory.tex
@@ -145,7 +145,7 @@ definion ensures
 \noindent
 and analogously for $\frac{b}{\gcd(a,\,b)}$. Note however,
 the convension $\gcd(0, 0) = 0$ is adhered. Therefore,
-before dividing with $\gcd{a, b}$ you may want to check
+before dividing with $\gcd(a, b)$ you may want to check
 whether $\gcd(a, b) = 0$.