\documentstyle[art11,fullpage]{article}
\title{X}
\author{}
\date{\today}
%\input{abbrev.tex}
\input{comm}

\begin{document}

{\Huge

\bi
\item 8-bit Numbers
\item []
\item The Negative of N, written as -N, is computed from 
	\[ 2^8 - N  = 100000000_2 - N \]
\item[] 
\item Example:
	\[ \begin{array}{l r}
		N = 0000 0011_2 &  \\
		-N = &	100000000_2 \\
		&	- 00000011_2 \\
		& 	\rule{1.5in}{0.5mm} \\
		-N = &	 11111101
	   \end{array}
	 \]
\item[]
\item {\bf Definition:} The negative of N is called the {\bf two's complement
of N} and is denoted by  {\bf 2comp(N)}
\ei

\newpage

\bi
\item \fbox{Math Tip:}
\item When calculating 2comp(N) use this ``shortcut''
\item 8-Bits
	\[	\begin{array}{l c l}
		2comp(N)	& =	& 2^8 - N_2 \\
				& =	& ((2^8 - 1) - N_2) + 1 \\
				& = 	& (1111 1111 - N_2 ) + 1
		\end{array}
	\]
\item This is a shortcut because $1111 1111 - N_2$ can be calculated by simply
replacing each $0$ by $1$, and each $1$ with $0$ in $N_2$. (You don't have to
worry so much about borrows).
\item Two Steps in Calculating 2comp(N)
	\be
	\item Complement N ; also called 1comp(N)
	\item Add 1
	\ee
\ei

\newpage

\fbox{N-bit Two's Complement Numbers}
\be
\item Two's complement n-bit numbers are binary numbers of length n. Bits are
indexed from 0 to $n-1$. For each bit $d_i$, the subscript corresponds to the
power of 2 in the binary expansion.
%
\item {\bf Range: } \( -2^{n-1} \;  \ldots  \; (2^{n-1}  - 1) \)
%
\item MSB = Sign bit; $1 \rightarrow -ive, \;\;\; 0 \rightarrow +ive $
%
\item For an n-bit number M, Negative of M is 2comp(M)
	\be 
	\item 2comp(M) = $2^n - M$
	\item Shortcut: 2comp(M) = 1Comp(M) + 1
	\ee
%
\item $\forall$ values of M, $M + 2comp(M) = 0$
	\bi
	\item Except for $-2^{n-1}$, $2comp(-2^{n-1}) = -2^{n-1}$ !!!!!!
	\ei
%
\newpage
\item {\bf Magnitude:} The magnitude of a negative number in two's complement
representation is hidden. You know it is negative because the MSB  =  1, but
what is its magnitude? 
	\bi
	\item Magnitude of a negative number is calculated by finding its two's
complement: 
		\bi 
		\item example: $M = 10001011_2$
		\item M is negative, because MSB = 1
		\item What is M's magnitude;  M is -ive what?
		\item $2comp(M) = 01110100_2 + 1 = 01110101_2 = 117_{10}$
		\item Therefore : M is $-117_{10}$
		\ei
	\ei
\ee

\newpage

\bi
\item []\fbox{2's complement Hex numbers}
\item We can compactly write binary numbers in HEX
\ei
\begin{verbatim}
Size = 8 bits
2's complement         Decimal value           HEX
0111 1111                  127                  7F
0111 1110                  126                  7E
0111 1101                  125                  7D
.....                    .....                .....
0000 0011                    3                  03
0000 0010                    2                  02
0000 0001                    1                  01
0000 0000                    0                  00
1111 1111                   -1                  FF
1111 1110                   -2                  FE
1111 1101                   -3                  FD
.....                    .....                 .....
1000 0010                 -126                  82
1000 0001                 -127                  81
1000 0000                 -128                  80
\end{verbatim}

\newpage

{\LARGE
\bi
\item[] {\Huge 2's complement Hex numbers} \ldots cont'd
%
\item[] 16-bit numbers
\item example 1: 2comp(06FD)
\[
\begin{array}{l c r}
	\begin{array}{r}
	2^{16} - 06FD \\
	\rule{1.5in}{0.9mm} \\
	10000 \\
	-06FD \\
	\rule{1.2in}{0.5mm} \\
	\\
	\\
	\\
	 F903 \\
	\rule{1.5in}{0.9mm} \\
	\end{array} &
	\mbox{\hspace{0.4in}OR\hspace{0.4in}} &
	\begin{array}{r}
	\mbox{SHORTCUT}\\
	\rule{1.5in}{0.9mm} \\
	 FFFF \\
	-06FD \\
	\rule{1.2in}{0.5mm} \\
	 F902 \\
	+0001 \\
	\rule{1.2in}{0.5mm} \\
	 F903 \\
	\rule{1.5in}{0.9mm} \\
	\end{array} 
\end{array} 
\]
\item[]
\item example 2: 2comp(903B)
\[
\begin{array}{l c r}
	\begin{array}{r}
	2^{16} - 903B \\
	\rule{1.5in}{0.9mm} \\
	10000 \\
	-903B \\
	\rule{1.2in}{0.5mm} \\
	\\
	\\
	\\
	 6FC5\\
	\rule{1.5in}{0.9mm} \\
	\end{array} &
	\mbox{\hspace{0.4in}OR\hspace{0.4in}} &
	\begin{array}{r}
	\mbox{SHORTCUT}\\
	\rule{1.5in}{0.9mm} \\
	 FFFF \\
	-903B \\
	\rule{1.2in}{0.5mm} \\
	 6FC4 \\
	+0001 \\
	\rule{1.2in}{0.5mm} \\
	 6FC5 \\
	\rule{1.5in}{0.9mm} \\
	\end{array} 
\end{array} 
\]
\ei
}  % end LARGE

}  % end HUGE
\end{document}
