What is a computer?
A
computer* is a machine that can be programmed to carry out sequences of arithmetic or logicaloperations* automatically. Each operation is described by a specificinstruction* orstatementto be performed. Modern digital electronic computers have a generic set ofoperationsandinstructions,* and they have the capability to execute specific sets of them known asprograms.* Eachprogramdescribes and implements analgorithm* to solve a specific problem (e.g. performing a calculation, storing and retrieving information from a database etc.). Theprogramsenable computers to perform a wide range of tasks. (cf. Wikipedia: Computers)Keywords:
digital computer;⇒ arithmetic operation;⇒ logical operation;⇒ instruction;⇒ instruction set;⇒ program⇒
A working definition of a digital computer:
A digital computer is a digital electronic machine that can be programmed to carry out sequences of operations automatically.
Examples
Example of a simple algorithm described by a flowchart diagram:
– arithmetic operation: + (addition)
– instructions: i←1 (assignment); i←i+1 (addition and assignment); write i (I/O instruction) etc.
– conditional instruction: (if) i>n (jump to stop); note that jump is performed when the i>n comparison provides 'true' logical value (i.e. 'yes')A possible implementation of the above algorithm is as follows:
var n=10; var i=1; while(i<=n) { writeln(i); i=i+1; } writeln("_____________");This small JavaScript program can be executed using a simple JS interpreter available here. Because JavaScript is a high-level programming language which does not contain conditional or unconditional 'jump' (or 'goto') statements, we should use the 'while' loop statement instead. The while(i<=n) {...} loop statement repeats the sequence (or 'block') of statements between the {...} curly brackets until the (i<=n) comparison (called the 'condition' of the loop) provides 'true' logical value.
What does digital mean?
A
digital* computer is a universal electronicdata processing* equipment which uses fixed-length sequences of binarydigits* to represent elementary or primitivetypes of data* (e.g. whole numbers or integers, real numbers, logical or Boolean values, characters etc.). Therepresentation of data* imposes specific coding rules and internal format upon each of the primitive and complexdata typesdefined in a computer system.Keywords:
data processing;⇒ data;⇒ information;⇒ digital;⇒ digit;⇒ data type(s);⇒ data representation⇒⇒⇒⇒⇒
Complex data types, e.g. strings, texts, long texts (cf. the "memo" field type, MS Access), arrays, database records etc., and various types of digital media (such as animations, digital images, sounds, videos etc.) also use binary encoding but the length and the number of the sequences of bits identifying elementary data units can be extremely diverse. For example, in a digital audio CD an elementary data unit can be 16 bits long (identifying the sound intensity at a given moment in one stereo channel), and the number of elementary data units depends on the actual length of the digitized sound.
Examples
Let us see some examples of the coding rules and internal format of a few elementary data types.
(1) examples of the coding rules and internal format of 8-bit integers:⇒
- 0 → 0000|0000
- 23 → 0001|0111
- −12 ⇒ 256−12=244 → 1111|0100
(2) examples of the coding rules and internal format of real ("floating point") numbers:⇒
- 4.5=1.125*22 ⇒ +(1+0.125)*2127+2 → 0 10000001 0010...
- −2.25=−1.125*21 ⇒ −(1+0.125)*2127+1 → 1 10000000 0010...
- 0.75=1.5*2−1 ⇒ (1+0.5)*2127−1 → 0 01111110 1000...
- −3=−1.5*21 ⇒ −(1+0.5)*2127+1 → 1 10000000 1000...
(3) examples of the coding rules and internal format of logical values:
- true ⇒ 1 → 00000001
- false ⇒ 0 → 00000000
(4) examples of the coding rules and internal format of ASCII characters (represented by a sequence of 7 bits):⇒
- ' ' ("space") ⇒ 32 → 0010|0000
- '0' ⇒ 48 → 0011|0000
- 'A' ⇒ 65 → 0100|0001