Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,

Similar presentations


Presentation on theme: "Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,"— Presentation transcript:

1 Data Representation

2 How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states, on or off Each transistor can represent one digit in a base 2 (binary) number All data must be converted to this form before it is stored in memory

3 Numeric (integer) data There are straightforward algorithms to convert integers in decimal and other bases to binary One bit is reserved to represent the sign of the number (signed magnitude representation) Examples in 8 bits: 47 10 = 00101111 2 -47 10 = 10101111 2

4 Hexadecimal Representation Decimal is relatively difficult to convert because the decimal digits of the number don't match up with groups of bits in the binary representation Base 8 (octal) and base 16 (hexadecimal) are easier because each digit corresponds to 3 or 4 bits in the binary representation.

5 The hexadecimal number system DecimalHexBinaryDecimalHexBinary 000000881000 110001991001 22001010A1010 33001111B1011 44010012C1100 55010113D1101 66011014E1110 77011115F1111

6 Example 10110000100101110110001011111101 D F 2 6 7 90 B Uses: HTML – representing color strings #FFCCFF First two digits are red component, next two are green, final two are blue HTML character entities &#169 is the character entity for the copyright symbol

7 Numeric (decimal) data We also need to store numbers like 239.23 Like integers, there are a set number of bits that are used to represent decimal numbers To simplify the problem, we use scientific notation: 239.23 = 2.3923 x 10 3 (except in binary)

8 IEEE Floating Point Format mantissa – the significant digits of the number, normalized so that there is one digit to the left of the decimal point (binary point, in this case) (also called "significand") exponent – power to which the mantissa is raised to get the original value sign bit – 0 for positive numbers, 1 for negative numbers

9 Numeric representation Gotchas Computers use a finite number of bits to store numeric data Some numbers are too big (or small) to fit in the available number of bits – overflow (or underflow) How many places after the decimal does 1/3 have? How about pi? Floating point representations are APPROXIMATIONS!

10 Textual Data How would you store "siphonapterology" in a computer's memory?

11 Textual Data How would you store "siphonapterology" in a computer's memory? We must find a way to encode the characters as numbers

12 Textual Data How would you store "siphonapterology" in a computer's memory? We must find a way to encode the characters as numbers ASCII – a simple encoding for the Latin alphabet, uses 7 bits per character, each character fits into one byte.

13 Textual Data How would you store "siphonapterology" in a computer's memory? We must find a way to encode the characters as numbers ASCII – a simple encoding for the Latin alphabet, uses 7 bits per character, each character fits into one byte. Unicode – 16 bits per character,works for more complex character sets

14 Images Divided into squares called pixels Each pixel is represented by a number The number encodes the color used to display that pixel

15 Programs? Programs must be stored in memory, too Every computer type has a "machine language instruction set" Each instruction has a binary code

16 10110000100101110110001011111101 What is it? A 32 bit negative integer value? A 32 bit negative floating point number? Four characters in ASCII encoding? Two characters in Unicode? Pixels from an image? Samples from a sound file? An instruction from a program? It depends – on how the value is used in the execution of a program.


Download ppt "Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,"

Similar presentations


Ads by Google