Logical operators Common arithmetic operators, like plus, minus, multiply and divide, works in any number base but the binary number system provides some further operators, called logical operators. Meaning can be assigned to the two binary states, such as yes and no, or true and false. Traditionally zero is assigned to false and one to true. Digital systems are said to be constructed by using logic gates. These gates are the AND, OR, NOT, NAND, NOR, EXOR. The basic operations are described below with the aid of truth tables. Gate AND OR NOT NAND NOR EXOR The AND gate is an electronic circuit that gives a high output (1) only if all its inputs are high. The OR gate is an electronic circuit that gives a high output (1) if one or more of its inputs are high. A plus (+) is used to show the OR operation. The NOT gate is an electronic circuit that produces an inverted version of the input at its output. It is also known as an inverter. If the input variable is A, the inverted output is known as NOT A. This is also shown as A', or A with a bar over the top, as shown at the outputs. This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate. The outputs of all NAND gates are high if any of the inputs are low. The symbol is an AND gate with a small circle on the output. The small circle represents inversion. This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of all NOR gates are low if any of the inputs are high. The symbol is an OR gate with a small circle on the output. The small circle represents inversion. The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not both, of its two inputs are high. An encircled plus sign () is used to show the EOR operation.
Binary Control systems can only tell the difference between two states, zero and one, and consequently they work in a number base that only has two symbols. They work in a number system with a base of two, the binary system. Data, in whatever form, are stored in binary. Hexadecimal The hexadecimal system has a base of 16, it is often called Hex for short. Binary is difficult and unwieldy for humans to deal with. Large numbers are even larger in binary. Doing quick conversions from binary into decimal is not possible. The fact that the base value of hex (16) is a power the base value of binary (two), I.D.16 equals 2^4, makes conversion between the two systems very easy. When technicians talk to each other about the actual stored values in the system, they use hex. Suppose a particular location in a computer's memory contains 1001110110011010. To convert from binary to hex, split the number into groups of four. 1001 1101 1001 1010 Then simply take each four digit binary number, converted to the decimal and substitute in the hex symbol. Binary 1001 1101 1001 1010 Decimal 9 13 9 10 Hex 9 D 9 A Convert these numbers from binary to hexadecimal. 1111111111111111 1011011110100001 0011001001000101 0001001000110100 Convert these numbers from hex to binary F1 A1 2222 58F9 ABDE BINARY CODED DECIMAL Pure binary is not the only way of storing numbers, another way is called Binary Coded Decimal (BCD).
Binary coded decimal-is a way of representing decimal numbers using four bits to hold the binary representation of the digits 0 through to 9. Groups of four bits are used to represent decimal digits. BCD 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 Decimal Hence 319 would be represented by 0011 0001 1001 4386 would be represented by 0100 0011 1000 0110 The circuits needed to manipulate numbers stored in BCD are much more complex than those used for arithmetic operations on pure binary numbers but the advantage is that the system is actually manipulating decimal numbers which makes it easier for it to format the numbers for output. How would these decimal numbers be represented in a computer using BCD? 748 22 41 38, 972 What decimal numbers to these BCD patterns represent? 000101011000 0101011110010110 10011001 10010100000101100110
ASCII In the early days of computers the different Manufacturer's all tended to use different codes to represent letters. This made it very difficult to move information from one Manufacturer's computer to another. The American National Standards Institute created a common code that everybody could use: ASCII, or to use its full name, American Standard Code for Information Interchange. ASCII officially uses seven bits to represent letters but most computers store them as eight bits largely because of the way computers are designed. The eighth bit is often used as a parity bit to check the data has been transferred without error. It is easiest to think of ASCII data as being held in groups of eight bits, the leftmost bit always being zero. Full 4 bit (Nibble) number system Binary Decimal Hexadecimal 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 10 A 1011 11 B 1100 12 C 1101 13 D 1110 14 E 1111 15 F
examples should be included. Numbers The two ways of storing numbers discussed above only store positive whole numbers (integers). What about fractions, decimals and negative numbers? Control systems need to use these for such quantities as weights and temperatures. Ways of storing binary equivalents of these values are needed. In the decimal numbering system the units column represents 2^0. Logic states therefore that any value to the right (the other side of the decimal point) have decreasing powers of 10. Fixed point The decimal point doesn't physically have to be stored as long as there is a way of finding out its position. Recall the smallest storage value in a computer is a bit. In early machines these were grouped into groups of eight bits called a byte. This was largely due to restrictions within the computers, architecture and although these restrictions have been lifted the traditional byte has remained, and consequently the storage of numbers has always been in multiples of eight bits. If all numbers are stored in 16 bits then using the fixed point method of storage this area can be defined so that a certain number of bits are to the left of the decimal point and the rest are to the right of the point. Let's assume that there are eight bits to the left of the point and eight bits to the right. Fixed point is a way of storing numbers in a computer system where the decimal point is assumed to be in a specific position. One of the problems of this method is that there is a limit to the size of a number. The biggest number using this method is 255.99609375. This number can be made bigger by changing the place of the decimal point. If there were four digits to the right and the rest to the left of the decimal point than the biggest number is 4095.9375. This is a bit better but the decimal values that can be represented are limited. This leads to less accuracy or precision. The position of the decimal point is actually a trade-off between the size of numbers and the numbers precision. Floating Point Floating point allows us to store a much larger range of numbers than fixed point but once again there is a trade-off with the precision of the number. Obviously using more bits would increase the precision of the number.