A Tutorial on Data Representation. Number Systems. Human beings use decimal (base 1. Computers use binary (base 2) number system, as they are made from binary digital components (known as transistors) operating in two states - on and off. In computing, we also use hexadecimal (base 1. Decimal (Base 1. 0) Number System.
7.1 REPRESENTATION OF FLOATING-POINT NUMBERS. Examples of floating-point numbers using a 4-bit fraction and 4-bit. VHDL Code for Floating-Point Multiplier. IEEE 754 Floating Point Representation Author: Alark Joshi Created Date: 10/10/2012 11:36:17 AM. IEEE 754 Floating-Point Format. Floating Point Representation – Basics. There are posts on representation of floating point format. Floating Point Representation. Floating Point Examples. Density of Floating Point Numbers Increase accuracy?
Representation of Floating Point Numbers in. The IEEE 754 single precision representation is given by: 1 10001010 00100101001001000000000. Normalized floating-point. Floating-point representation is an alternative technique based on scientific notation. Floating-point basics. The floating-point representation is by far the most.
Decimal number system has ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, called digits. It uses positional notation. That is, the least- significant digit (right- most digit) is of the order of 1. For example. 7. 35 = 7. It is also a positional notation, for example. B = 1. Some programming languages denote binary numbers with prefix 0b (e. A binary digit is called a bit.
Eight bits is called a byte (why 8- bit unit? Probably because 8=2. Hexadecimal (Base 1. Number System. Hexadecimal number system uses 1. A, B, C, D, E, and F, called hex digits. It is a positional notation, for example.
A3. EH = 1. 0. Some programming languages denote hex numbers with prefix 0x (e. A3. C5. F), or prefix x with hex digit quoted (e. C3. A4. D9. 8B'). Each hexadecimal digit is also called a hex digit. Most programming languages accept lowercase 'a' to 'f' as well as uppercase 'A' to 'F'. Computers uses binary system in their internal operations, as they are built from binary digital electronic components. However, writing or reading a long sequence of binary bits is cumbersome and error- prone.
Hexadecimal system is used as a compact form or shorthand for binary bits. Each hex digit is equivalent to 4 binary bits, i. H (0. 00. 0B) (0. D)1. H (0. 00. 1B) (1. D)2. H (0. 01. 0B) (2.
D)3. H (0. 01. 1B) (3. D)4. H (0. 10. 0B) (4. D)5. H (0. 10. 1B) (5. D)6. H (0. 11. 0B) (6. D)7. H (0. 11. 1B) (7. D)8. H (1. 00. 0B) (8.
D)9. H (1. 00. 1B) (9. D)AH (1. 01. 0B) (1. D)BH (1. 01. 1B) (1. D)CH (1. 10. 0B) (1.
D)DH (1. 10. 1B) (1. D)EH (1. 11. 0B) (1. D)FH (1. 11. 1B) (1. D)Conversion from Hexadecimal to Binary. Replace each hex digit by the 4 equivalent bits, for examples.
A3. C5. H = 1. 01. B. 1. 02. AH = 0. BConversion from Binary to Hexadecimal.
Starting from the right- most bit (least- significant bit), replace each group of 4 bits by the equivalent hex digit (pad the left- most bits with zero if necessary), for examples. B = 0. 01. 0 0. 10. B = 2. 4AH. 1. 00.
B = 0. 01. 0 0. 01. B = 2. 2CBHIt is important to note that hexadecimal number provides a compact form or shorthand for representing binary bits.
Conversion from Base r to Decimal (Base 1. Given a n- digit base r number: dn- 1 dn- 2 dn- 3 .. For example. To convert 2. D to hexadecimal. Hence, 2. 61. D = 1. HThe above procedure is actually applicable to conversion between any 2 base systems.
For example. To convert 1. D remainder=0. 2. D/3 => quotient=8. D remainder=1. 8. D/3 => quotient=2.
D remainder=2. 2. D/3 => quotient=0 remainder=2 (quotient=0 stop). Hence, 1. 02. 3(base 4) = 2. General Conversion between 2 Base Systems with Fractional Part.
Separate the integral and the fractional parts. For the integral part, divide by the target radix repeatably, and collect the ramainder in reverse order. For the fractional part, multiply the fractional part by the target radix repeatably, and collect the integral part in the same order.
Example 1: Convert 1. D to binary. Integral Part = 1. D. 1. 8/2 => quotient=9 remainder=0. Hence, 1. 8D = 1. B. Fractional Part = . D. . 6. 87. 5*2=1.
Hence . 6. 87. 5D = . B. Therefore, 1. 8.
D = 1. 00. 10. 1. BExample 2: Convert 1. D to hexadecimal.
Integral Part = 1. D. 1. 8/1. 6 => quotient=1 remainder=2.
Hence, 1. 8D = 1. H. Fractional Part = . D. . 6. 87. 5*1. 6=1. D (BH). Hence . 6. D = . BH. Therefore, 1. D = 1. 2. BHExercises (Number Systems Conversion)Convert the following decimal numbers into binary and hexadecimal numbers.
Convert the following binary numbers into hexadecimal and decimal numbers. Convert the following hexadecimal numbers into binary and decimal numbers. ABCDE1. 23. 48. 0FConvert the following decimal numbers into binary equivalent.
D1. 23. 4. 56. DAnswers: You could use the Windows' Calculator (calc. A n- bit storage location can represent up to 2^n distinct entities. For example, a 3- bit memory location can hold one of these eight binary patterns: 0.
Hence, it can represent at most 8 distinct entities. You could use them to represent numbers 0 to 7, numbers 8. A' to 'H', or up to 8 kinds of fruits like apple, orange, banana; or up to 8 kinds of animals like lion, tiger, etc. Integers, for example, can be represented in 8- bit, 1.
You, as the programmer, choose an appropriate bit- length for your integers. Your choice will impose constraint on the range of integers that can be represented. Besides the bit- length, an integer can be represented in various representation schemes, e. An 8- bit unsigned integer has a range of 0 to 2.
It is important to note that a computer memory location merely stores a binary pattern. Furthermore, it is important that the data representation schemes are agreed- upon by all the parties, i. Once you decided on the data representation scheme, certain constraints, in particular, the precision and range will be imposed.
Hence, it is important to understand data representation to write correct and high- performance programs. Rosette Stone and the Decipherment of Egyptian Hieroglyphs. Egyptian hieroglyphs (next- to- left) were used by the ancient Egyptians since 4.
BC. The decree appears in three scripts: the upper text is Ancient Egyptian hieroglyphs, the middle portion Demotic script, and the lowest Ancient Greek. Because it presents essentially the same text in all three scripts, and Ancient Greek could still be understood, it provided the key to the decipherment of the Egyptian hieroglyphs. The moral of the story is unless you know the encoding scheme, there is no way that you can decode the data. Reference and images: Wikipedia.
Integer Representation. Integers are whole numbers or fixed- point numbers with the radix point fixed after the least- significant bit.
They are contrast to real numbers or floating- point numbers, where the position of the radix point varies. It is important to take note that integers and floating- point numbers are treated differently in computers.
They have different representation and are processed differently (e. Floating- point numbers will be discussed later. Computers use a fixed number of bits to represent an integer. The commonly- used bit- lengths for integers are 8- bit, 1.
Besides bit- lengths, there are two representation schemes for integers: Unsigned Integers: can represent zero and positive integers. Signed Integers: can represent zero, positive and negative integers. Three representation schemes had been proposed for signed integers. Sign- Magnitude representation. Complement representation. Complement representation.
You, as the programmer, need to decide on the bit- length and representation scheme for your integers, depending on your application's requirements. Suppose that you need a counter for counting a small quantity from 0 up to 2. Unsigned Integers.
Unsigned integers can represent zero and positive integers, but not negative integers. An n- bit unsigned integer can represent integers from 0 to (2^n)- 1, as tabulated below: n.
Minimum. Maximum. Signed Integers. Signed integers can represent zero, positive integers, as well as negative integers. Three representation schemes are available for signed integers: Sign- Magnitude representation. Complement representation. Complement representation. In all the above three schemes, the most- significant bit (msb) is called the sign bit.
The sign bit is used to represent the sign of the integer - with 0 for positive integers and 1 for negative integers. The magnitude of the integer, however, is interpreted differently in different schemes. Sign Integers in Sign- Magnitude Representation. In sign- magnitude representation: The most- significant bit (msb) is the sign bit, with value of 0 representing positive integer and 1 representing negative integer. The remaining n- 1 bits represents the magnitude (absolute value) of the integer.
The absolute value of the integer is interpreted as . Computers use 2's complement in representing signed integers. This is because: There is only one representation for the number zero in 2's complement, instead of two representations in sign- magnitude and 1's complement.
Positive and negative integers can be treated together in addition and subtraction. Subtraction can be carried out using the . For example, for n=8, the range of 2's complement signed integers is - 1. During addition (and subtraction), it is important to check whether the result exceeds this range, in other words, whether overflow or underflow has occurred.
Example 4: Overflow: Suppose that n=8, 1. D + 2. D = 1. 29. D (overflow - beyond the range).
D . By re- arranging the number line, values from - 1. Range of n- bit 2's Complement Signed Integers. An n- bit 2's complement signed integer can represent integers from - 2^(n- 1) to +2^(n- 1)- 1, as tabulated. Take note that the scheme can represent all the integers within the range, without any gap. In other words, there is no missing integers within the supported range. Decoding 2's Complement Numbers. Check the sign bit (denoted as S).
If S=0, the number is positive and its absolute value is the binary value of the remaining n- 1 bits. If S=1, the number is negative. The flipped pattern gives the absolute value. For example. n = 8, bit pattern = 1 1. B. S = 1 . Little Endian.
Modern computers store one byte of data in each memory address or location, i. An 3. 2- bit integer is, therefore, stored in 4 memory addresses. The term. An 1. 6- bit integer 0. H 0. 1H is interpreted as 0. H in big endian, and 0.
H as little endian. Exercise (Integer Representation)What are the ranges of 8- bit, 1. The range of n- bit 2's complement signed integer is .
Decimal numbers use radix of 1. F. This is because there are infinite number of real numbers (even within a small range of says 0. On the other hand, a n- bit binary pattern can represent a finite.