clarify documentation of mp_div_2d() and mp_mul_2d()

This commit is contained in:
Steffen Jaeckel 2014-12-11 22:44:50 +01:00 committed by Tom St Denis
parent 183350603c
commit 8432c4eda5
2 changed files with 9 additions and 5 deletions

10
bn.tex
View File

@ -1076,7 +1076,9 @@ If this program is successful it will print out the following text.
2*number/2 < 7
\end{alltt}
Since $10 > 7$ and $5 < 7$. To multiply by a power of two the following function can be used.
Since $10 > 7$ and $5 < 7$.
To multiply by a power of two the following function can be used.
\index{mp\_mul\_2d}
\begin{alltt}
@ -1084,7 +1086,8 @@ int mp_mul_2d(mp_int * a, int b, mp_int * c);
\end{alltt}
This will multiply $a$ by $2^b$ and store the result in ``c''. If the value of $b$ is less than or equal to
zero the function will copy $a$ to ``c'' without performing any further actions.
zero the function will copy $a$ to ``c'' without performing any further actions. The multiplication itself
is implemented as a right-shift operation of $a$ by $b$ bits.
To divide by a power of two use the following.
@ -1094,7 +1097,8 @@ int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
\end{alltt}
Which will divide $a$ by $2^b$, store the quotient in ``c'' and the remainder in ``d'. If $b \le 0$ then the
function simply copies $a$ over to ``c'' and zeroes $d$. The variable $d$ may be passed as a \textbf{NULL}
value to signal that the remainder is not desired.
value to signal that the remainder is not desired. The division itself is implemented as a left-shift
operation of $a$ by $b$ bits.
\subsection{Polynomial Basis Operations}

View File

@ -299,13 +299,13 @@ void mp_rshd(mp_int *a, int b);
/* left shift by "b" digits */
int mp_lshd(mp_int *a, int b);
/* c = a / 2**b */
/* c = a / 2**b, implemented as c = a >> b */
int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d);
/* b = a/2 */
int mp_div_2(mp_int *a, mp_int *b);
/* c = a * 2**b */
/* c = a * 2**b, implemented as c = a << b */
int mp_mul_2d(mp_int *a, int b, mp_int *c);
/* b = a*2 */