Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Systems and Representations Binary Representation Binary Representation Signed numbers Signed numbers Very small and very big numbers Very small.

Similar presentations


Presentation on theme: "Number Systems and Representations Binary Representation Binary Representation Signed numbers Signed numbers Very small and very big numbers Very small."— Presentation transcript:

1 Number Systems and Representations Binary Representation Binary Representation Signed numbers Signed numbers Very small and very big numbers Very small and very big numbers Accurate arithmetic with binary representations Accurate arithmetic with binary representations 15-213 F’02 class02.ppt

2 – 2 – 15-213, F’02 Why Digital ? Analog Computers: numbers are represented with signal levels Not practical due to low accuracy An analog signal:

3 – 3 – 15-213, F’02 Why Don’t Computers Use Base 10? Base 10 Number Representation That’s why fingers are known as “digits” Natural representation for financial transactions Floating point number cannot exactly represent $1.20 Even carries through in scientific notation 1.5213 X 10 4 Implementing Electronically Hard to store ENIAC (First electronic computer) used 10 vacuum tubes / digit Hard to transmit Need high precision to encode 10 signal levels on single wire Messy to implement digital logic functions Addition, multiplication, etc.

4 – 4 – 15-213, F’02 Binary Representations Base 2 Number Representation Represent 15213 10 as 11101101101101 2 Represent 1.20 10 as 1.0011001100110011[0011]… 2 Represent 1.5213 X 10 4 as 1.1101101101101 2 X 2 13 Electronic Implementation Easy to store with bistable elements Reliably transmitted on noisy and inaccurate wires 0.0V 0.5V 2.8V 3.3V 010

5 – 5 – 15-213, F’02 Encoding Byte Values Byte = 8 bits Binary 00000000 2 to 11111111 2 Decimal: 0 10 to 255 10 Hexadecimal 00 16 to FF 16 Base 16 number representation Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’ Write FA1D37B 16 in C as 0xFA1D37B »Or 0xfa1d37b 000000 110001 220010 330011 440100 550101 660110 770111 881000 991001 A101010 B111011 C121100 D131101 E141110 F151111 Hex Decimal Binary

6 – 6 – 15-213, F’02 Machine Words Machine Has “Word Size” Nominal size of integer-valued data Most current machines are 32 bits (4 bytes) Limits addresses to 4GB Becoming too small for memory-intensive applications High-end systems are 64 bits (8 bytes) Potentially address  1.8 X 10 19 bytes Machines support multiple data formats Fractions or multiples of word size Always integral number of bytes

7 – 7 – 15-213, F’02 Word-Oriented, Byte Addressed Memory Organization Addresses Specify Byte Locations Address of first byte in word Addresses of successive words differ by 4 (32-bit) or 8 (64-bit) 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 32-bit Words BytesAddr. 0012 0013 0014 0015 64-bit Words Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ?? Addr = ?? 0000 0004 0008 0012 0000 0008

8 – 8 – 15-213, F’02 Data Representations Sizes of C Objects (in Bytes) C Data TypeCompaq AlphaTypical 32-bitIntel IA32 int444 long int844 char111 short222 float444 double888 long double8810/12 char *844 »Or any other pointer

9 – 9 – 15-213, F’02 Byte Ordering How should bytes within multi-byte word be ordered in memory? Conventions Sun’s, Mac’s are “Big Endian” machines Least significant byte has highest address Alphas, PC’s are “Little Endian” machines Least significant byte has lowest address

10 – 10 – 15-213, F’02 Byte Ordering Example Big Endian Least significant byte has highest address Little Endian Least significant byte has lowest addressExample Variable x has 4-byte representation 0x01234567 Address given by &x is 0x100 0x1000x1010x1020x103 01234567 0x1000x1010x1020x103 67452301 Big Endian Little Endian 01234567 452301

11 – 11 – 15-213, F’02 Reading Byte-Reversed Listings Disassembly Text representation of binary machine code Generated by program that reads the machine code Example Fragment AddressInstruction CodeAssembly Rendition 8048365:5b pop %ebx 8048366:81 c3 ab 12 00 00 add $0x12ab,%ebx Deciphering Numbers Value: 0x12ab Pad to 4 bytes: 0x000012ab Split into bytes: 00 00 12 ab Reverse: ab 12 00 00

12 – 12 – 15-213, F’02 Endian Concept User transparent User transparent Important to know when data is transferred between machines with different standards Important to know when data is transferred between machines with different standards


Download ppt "Number Systems and Representations Binary Representation Binary Representation Signed numbers Signed numbers Very small and very big numbers Very small."

Similar presentations


Ads by Google