The bit is a very small amount of information. A typical example is a light switch. It is on or it is off. It is safe to think that all information in a computer is stored and transmitted as bits. The manner that this is done varies. Some bit may be a group of photons in a fiber optic cable, another may be a magnetic domain in a disk drive, or a small amount of electric charge in a DRAM (Dynamic Random Access Memory) storage cell. These bits can be short lived or very permanent, depending on the use and the storage method. There organization can be serial, one bit in time after another such as EIA RS-232 and Ethernet, parallel (such as central memory in a computer, or block structured (as on a disk drive).
Most computer systems have been programmed or hardwired to shift from on form to another.
An individual single bit can be very important (or totally unused). It is a matter of interpretation. A bit can affect data transmission rate, change a "B" to a "C" (in ASCII), change the register used in a instruction, the location used for an instruction, change the address used by an instruction to the data used by an instruction, blow up a bomb, or miss-route a phone call.
Bits are often used on an individual basis. For example is A<B represents a bit. Are you male or female. Is a door locked or unlocked. Is your computer system using its paging system or not. (There is one bit that will be set to turn it on.)
There are various logical functions that can and are performed on bits. AND, OR, XOR (exclusive OR), NOT. Computer systems will usually have instructions for doing this type of operation.
Bits are more often thought of as part of a larger group. Small collections of bits are nibbles (4 bits), bytes (8 bits - sometimes 7 bits and sometimes 9 bits), words (12, 16, 18, 32, 40, 48, 64, 80, 128, 256, 512 bits [and other values too!] depending on the content and the system, blocks (groups of bytes or words), and clusters (groups of blocks)
One bit is not much information. It only has two possible states. It is when you have multiple bits that thing get interesting! Two bit can have different states. 00, 01, 10, and 11. Another way to look at it is 2*2. Each bit having two values. Three bits yields eight possibilities. Eight bits has 255. Ten bits has 1024, and 256 bits has 115792089237316195423570985008687907853269984665640564039457584007913129639936. For 512 bits you will bits to square that number. For a disk sector on an IBM PC with 512 bytes you will need to square that result twice, or
Each of these possibilities could be used for something different. If you use more bits, it costs more. You could use 32 bits for a character set instead of 7 or 8. Your data files would be 4 times larger and transmission time would take 4 times longer. It is a trade off that has been made. (An early TTY and most current TTY's used by deaf people to communicate use Baudot code with only 5 bits.)1044388881413152506691752710716624382579964249047383780384 2334832839539079715574568488268119349975583408901067144392 6283798757343818579360726323608785136527794595697654370999 8340361590134383718314428070011855946226376318839397712745 6723346843445866174968079087058037040712840487401186091144 6797778359802900668693897688178778594690563019026094059957 9453432823469303026696443059025015972399867714215541693835 5598852914863182379144344967340878118726394964751001890413 4900841706167509366833385055103297208826955076998361636941 1933015213796825837188091833656751221318492846368125550225 9983004123447848625956744921946170238065059132456108257318 3538008760862210283427019769820231316901767800667519548507 9921636419370285375124784014907159135459982790513399611551 7942711068311340905842728842797915548497829543235345170652 2326906139490598769300212296339568778287894844061600741294 5674919823050571642377154816321380631045902916136926708342 8564407304478999719017814657634732238502672530598997959960 9079946920177462481771844986745565925017832907047311943316 5550807568221846571746373296884912819520317457002440926616 9108741483850784119298045229818573389776481031260859030013 0241346718972667321649151113160292078173803343609024380470 8340403154190336
The same trade off occurs with numbers. What numbers are you really going to use? Is two digits enough for a year. Are you ever going to have more than 31 days in a month? How big will your a account get. Remember you might want Bill Gates as a customer.
One of the simplest uses of a group of bits is fixed point numbers and character data. I will look at character representations first.
There exists many other standards including International Character Sets, 16 bit character encoding, Kanji, EBCDIC (See: Nance & Naps Chapter 3 page 73 and Appendix 4 page A.17), and Hollerith Code.
Character sets are remarkably arbitrary. Someone (or a committee) chooses what set of ones and zeros represents what character. As long as everyone agrees, it works great. In ASCII, the character "A" is represented by the 7 bits 0 1 0 0 0 0 0 1. ASCII works well in the United States. England has problems. We use a dollar sign "$". England uses a pound sign "£". Other symbols that are not in the ASCII character set include Å, å, Æ, æ, Ø, ø, OE, oe, ß, ¿, ¡, ©, ¶, and §.
There are other character sets to solve some of the problems. But, as yet, no character set solves all of the problems. (For example Kanji and Sanskrit)
Powers of 2 n
2n 8 256 16 65536 32 4294967296 64 18446744073709551616
There are some VERY common schemes for dealing with fixed point numbers. This allows for the use of specific instructions in a machine, such as add and subtract. You can STILL do this with scaled numbers if you are careful.
This is of fundamental importance. If you produced different results in binary or in decimal who would want to use computers?
Computers for the most part use binary numbers. Binary numbers are long and difficult for people to deal with. In fact, most people have been dealing with decimal numbers most of their lives, and probably don't want to switch. As an example of what I mean by difficult lets look at a large binary number
in decimal it is 5,840,975,345,450. Yep, a big number. Which one would be easiest to copy correctly? Remember one bit can make a big difference.1010100111111110101010000101011011100101010
If you wanted the decimal number in binary, changing the representation, you would probably want to use a computer. To do it by hand or by computer you need to divide the number by the base you are converting to, over and over again. Each remainder will give you one digit.
If you need to know which bits are one and which are zero internally in a machine, binary helps. But it is very error prone. To get around this problem people have used octal (base 8) and hexadecimal (base 16) numbers. For hexadecimal numbers we need some new characters to represent the value past 9. These are shown in the following table:
Hexadecimal Character Values Character
Decimal Value Binary Value 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111
So for the big binary number above:
Note that as more information is packed into a character position, you need less characters to represent a number.Base Number 2 1010100111111110101010000101011011100101010 8 124776520533452 10 5840975345450 16 54FF542B72A
If you are dealing with unsigned integers, The usual representation used is binary. Each bit has twice the weight of the preceding bit. When all bits are zero, the value of the number is zero. So a one bit binary number has a minimum value of zero and a maximum value of 1. For 8 bits, the minimum is 0 and the maximum is 255. A table follows for some common unsigned integer sizes.
Minimum and Maximum Values for Unsigned Numbers Bits
Minimum Maximum 2n-1 8 0 256 16 0 65536 32 0 4294967296 64 0 18446744073709551616
For 2's complement signed integers the most significant bit takes on the value of -2n-1. So for a 8 bit number the MSB (or Most Significant Bit) has a numeric value of -128. This gives us a range of values of -128 to 127. For 2's complement numbers out table looks like this:
Minimum and Maximum Values for Signed Numbers Bits
Minimum -2n-1 Maximum 2n-1-1 8 -128 127 16 -32768 32767 32 -2147483648 2147483647 64 -9223372036854775808 9223372036854775807
Please note that this representation for signed numbers has one more negative number than positive numbers. This can cause problems.
BCD Character Values Binary
Decimal Value 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 10
This leaves 6 other bit combinations. Typically at least two will be assigned meanings. One for a negative sign. The other for the end of the number. (When we get to character strings, this works the same way.) The reason for using this scheme is FAST input/output conversion. In a business setting where the amount of arithmetic that is done is small, sometimes the computation to convert in the number to/from binary/decimal exceeds the computation done with the number. Some systems (IBM & 8080) support some form of BCD arithmetic. I expect that some implementations of COBOL will store certain types of numbers in a BCD format.
Addition and subtraction can be done without any adjustment. Multiplication and division need to be adjusted. Some hardware designs account for this, in other cases the programmer or the compiler need to make the adjustment. Binary, Octal, Hexadecimal, Decimal
Floating point hardware will often support a few enumerated items. Usually referred to as NaN or Not a Number. Intel supports several NaNs. Both signaling (creates an exception) and quiet. The NaNs are indicated by a specific exponent. In Intel's case all of the exponent bits are set to one. These values are primarily use to represent positive and negative infinity.
Most computer systems support floating point in hardware today. Small embedded computers may not. Hardware simply does it faster, it can be done in software. Super computer systems are often measured in how many floating point operations it can perform in a second. The Intel Ultra computer is rated at over 1,000,000,000,000 floating point operation per second. It is composed of over 9,000 Pentium-pro processors.
It is also easy to think of instructions as a packed structure. In the structure you will find various fields. The fields, depending on the computer's instruction set can contain the following: