Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 23 additions & 32 deletions input/chapter01/chapter01.xml
Original file line number Diff line number Diff line change
Expand Up @@ -503,31 +503,26 @@
<info>
<title>Boolean Operations</title>
</info>
<para>George Boole was a mathematician who discovered a whole
area of mathematics called <emphasis>Boolean
Algebra</emphasis>. Whilst he made his discoveries in the mid
1800's, his mathematics are the fundamentals of all computer
science. Boolean algebra is a wide ranging topic, we present
here only the bare minimum to get you started.</para>
<para>Boolean operations simply take a particular input and
produce a particular output following a rule. For example,
the simplest boolean operation,
<computeroutput>not</computeroutput> simply inverts the value
of the input operand. Other operands usually take two inputs,
<para>George Boole was a mathematician whose work on set theory
is now called <emphasis>Boolean
Algebra</emphasis>.</para>
<para>The simplest boolean operation,
<computeroutput>not</computeroutput> inverts the value
of the input. Other operands take two inputs,
and produce a single output.</para>
<para>The fundamental Boolean operations used in computer
science are easy to remember and listed below. We represent
them below with <emphasis>truth tables</emphasis>; they simply
science are listed below. We represent
them below with <emphasis>truth tables</emphasis>; these
show all possible inputs and outputs. The term
<emphasis>true</emphasis> simply reflects
<emphasis>true</emphasis> is
<computeroutput>1</computeroutput> in binary.</para>
<section>
<info>
<title>Not</title>
</info>
<para>Usually represented by
<computeroutput>!</computeroutput>,
<computeroutput>not</computeroutput> simply inverts the
<computeroutput>not</computeroutput> inverts the
value, so <computeroutput>0</computeroutput> becomes
<computeroutput>1</computeroutput> and
<computeroutput>1</computeroutput> becomes
Expand Down Expand Up @@ -568,7 +563,7 @@
<info>
<title>And</title>
</info>
<para>To remember how the and operation
<para>To remember how the <computeroutput>and</computeroutput> operation
works think of it as "if one input <emphasis>and</emphasis>
the other are true, result is true</para>
<table>
Expand Down Expand Up @@ -863,16 +858,13 @@
<para>Hexadecimal refers to a base 16 number system. We use
this in computer science for only one reason, it makes it easy
for humans to think about binary numbers. Computers only ever
deal in binary and hexadecimal is simply a shortcut for us
deal in binary; hexadecimal is a shortcut for us
humans trying to work with the computer.</para>
<para>So why base 16? Well, the most natural choice is base 10,
since we are used to thinking in base 10 from our every day
number system. But base 10 does not work well with binary -- to
represent 10 different elements in binary, we need four bits.
Four bits, however, gives us sixteen possible combinations. So
we can either take the very tricky road of trying to convert
between base 10 and binary, or take the easy road and make up a
base 16 number system -- hexadecimal!</para>
Four bits, however, gives us sixteen possible combinations -- too many.</para>
<para>Hexadecimal uses the standard base 10 numerals, but adds
<computeroutput>A B C D E F</computeroutput> which refer to
<computeroutput>10 11 12 13 14 15</computeroutput> (n.b. we
Expand Down Expand Up @@ -1081,10 +1073,10 @@
(say, assign G to the value 16), but 16 values is an excellent
trade off between the vagaries of human memory and the number of
bits used by a computer (occasionally you will also see base 8
used, for example for file permissions under UNIX). We simply
used, for example for file permissions under UNIX). We
represent larger numbers of bits with more numerals. For
example, a sixteen bit variable can be represented by 0xAB12,
and to find it in binary simply take each individual numeral,
and to find it in binary take each individual numeral,
convert it as per the table and join them all together (so
<computeroutput>0xAB12</computeroutput> ends up as the 16-bit
binary number
Expand Down Expand Up @@ -1665,9 +1657,9 @@
<info>
<title>Sign Bit</title>
</info>
<para>The most straight forward method is to simply say that
one bit of the number indicates either a negative or
positive value depending on it being set or not.</para>
<para>The most straight forward method is to let
one bit indicates negative or
positive.</para>
<para>This is analogous to mathematical approach of having a
<computeroutput>+</computeroutput> and
<computeroutput>-</computeroutput>. This is fairly logical,
Expand All @@ -1677,7 +1669,7 @@
easier.</para>
<para>However, notice that the value
<computeroutput>0</computeroutput> now has two equivalent
values; one with the sign bit set and one without.
values: one with the sign bit set and one without.
Sometimes these values are referred to as
<computeroutput>+0</computeroutput> and
<computeroutput>-0</computeroutput> respectively.</para>
Expand All @@ -1686,16 +1678,15 @@
<info>
<title>One's Complement</title>
</info>
<para>One's complement simply applies the
<emphasis>not</emphasis> operation to the positive number to
represent the negative number. So, for example the value
<para>One's complement applies the
<emphasis>not</emphasis> operation to a positive number to
represent its negative. So, for example the value
-90 (-0x5A) is represented by <computeroutput>~01011010 =
10100101</computeroutput><footnote><para>The
<computeroutput>~</computeroutput> operator is the C
language operator to apply
<computeroutput>NOT</computeroutput> to the value. It is
also occasionally called the one's complement operator, for
obvious reasons now!</para></footnote></para>
also occasionally called the one's complement operator.</para></footnote></para>
<para>With this scheme the biggest advantage is that to add
a negative number to a positive number no special logic is
required, except that any additional carry left over must be
Expand Down