Definition:Classical Algorithm/Primitive Subtraction

From ProofWiki
Jump to navigation Jump to search

Definition

The primitive operation for subtraction which can be used in the classical algorithms is:

Let $x$ and $y$ be $1$-digit integers.

Let $z$ be a carry digit such that either $z = 0$ or $z = -1$.

Subtraction of $y$ from $x$ with $z$ gives a $1$-digit difference $d$ and a $1$-digit carry $c$ such that:


\(\ds d\) \(=\) \(\ds \paren {x - y + z} \pmod b\)
\(\ds c\) \(=\) \(\ds \floor {\dfrac {x - y + z} b}\)
\(\ds \) \(=\) \(\ds \begin{cases} 0 & : x - y + z \ge 0 \\ -1 & : x - y + z < 0 \end{cases}\)




In this context, the carry digit is often referred to as a borrow.


Base $10$ Subtraction Table

The primitive subtraction operation for conventional base $10$ arithmetic on two $1$-digit integers can be presented as a pair of operation tables as follows:

$\begin{array}{c|cccccccccc}

d & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline 0 & 0 & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 \\ 1 & 1 & 0 & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 \\ 2 & 2 & 1 & 0 & 9 & 8 & 7 & 6 & 5 & 4 & 3 \\ 3 & 3 & 2 & 1 & 0 & 9 & 8 & 7 & 6 & 5 & 4 \\ 4 & 4 & 3 & 2 & 1 & 0 & 9 & 8 & 7 & 6 & 5 \\ 5 & 5 & 4 & 3 & 2 & 1 & 0 & 9 & 8 & 7 & 6 \\ 6 & 6 & 5 & 4 & 3 & 2 & 1 & 0 & 9 & 8 & 7 \\ 7 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 & 9 & 8 \\ 8 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 & 9 \\ 9 & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\ \end{array} \qquad \begin{array}{c|cccccccccc} c & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ \hline 0 & 0 & 1 & 1 & 1 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