Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Representation – Chapter 3 Section 3-1. Terminology “Digital” –Discrete, well defined values/steps –Opposite of analog –Analogy: digital is to analog.

Similar presentations


Presentation on theme: "Data Representation – Chapter 3 Section 3-1. Terminology “Digital” –Discrete, well defined values/steps –Opposite of analog –Analogy: digital is to analog."— Presentation transcript:

1 Data Representation – Chapter 3 Section 3-1

2 Terminology “Digital” –Discrete, well defined values/steps –Opposite of analog –Analogy: digital is to analog as int is to double “Binary” –A system consisting of two states –on/off, true/false, yes/no, high/low, 0/1 –Basis for modern computers

3 Terminology “Bit” –Binary-digit –Smallest unit of storage in modern computers

4 Data Representation 1000001 – what does this “mean”? –one million, one –sixteen million, seven hundred seventy seven thousand, two hundred, seventeen –two hundred sixty two thousand, one hundred forty five –sixty five –“A” –AJMP assembly language instruction

5 Data Representation 1000001 –Decimal number –Hexadecimal number –Octal number –Binary number –ASCII character –8051 machine instruction

6 Number Systems A number system is defined by its base or radix –The number of unique digits used in the system –Digits range in value from 0 to radix-1 –Larger values are created by stringing together digits Resultant value is defined by d: digit, b: base, i: position with 0 being the first position to the left of the “base point”, increasing to the left, decreasing to the right

7 Number Systems Binary is convenient/efficient for use in a computer… –Electronic circuits can be easily designed to deal with two distinct levels e.g. TTL 0-volts and 5-volts … but extremely inconvenient for human consumption –Humans were designed to work with ten distinct levels e.g. fingers We’ll concentrate on decimal, hexadecimal, octal, and binary

8 Conversion Base b to decimal, b = 2 (binary) Decimal to base b –Integer divide value by b –Output remainder –Repeat on quotient –Until quotient is zero ValueQuotient Value / 2 Remainder Value % 2 941 420 210 101

9 Conversion Binary to octal –Separate binary number into groups of 3 binary digits padding the left with 0’s if necessary –Convert groups to decimal digits 1001 2 -> 001 001 -> 11 8

10 Conversion Binary to hexadecimal –Separate binary number into groups of 4 binary digits padding the left with 0’s if necessary –Convert groups to decimal digits 1010 2 -> 1010 -> 10 16 (?) –Not exactly 10 10 —15 10 -> A 16 —F 16 i.e. 0123456789ABCDEF

11 Conversion Octal to hexadecimal and hexadecimal to octal –Convert to binary then to the target radix using previous methods

12 Conversion Octal and hexadecimal are useful when working closely with the architecture –Designing circuits –Designing device interfaces –Writing assembly language programs In such situations one is generally concerned with bit patterns rather than the decimal value The conversions can be done in your head

13 Assignment 1.Write a Java program that takes in a decimal number and prints out the binary representation prints out the octal representation prints out the hexadecimal representation 2.Write a Java program that takes in an binary number and prints out the octal representation prints out the decimal representation prints out the hexadecimal representation 3.Write a Java program that takes in an octal number and prints out the binary representation prints out the decimal representation prints out the hexadecimal representation 4.Write a Java program that takes in a hexadecimal number and prints out the binary representation prints out the octal representation prints out the decimal representation DO NOT utilize Java API functions Integer.toHexString() Integer.toOctalString() Integer.toBinaryString() or any other API or formatting functions that I might have overlooked that do the conversions for you!!! You are to do this by pulling digits from numbers using addition, subtraction, multiplication, division, modulo, or any other arithmetic operators and then doing the specified mathematical operations for the conversion

14 Assignment Turn in –Print out of your code –Print out of the results (inputs and outputs) of your code (this can be screen shots) –Please make sure your code actually works and produces the proper answers (i.e. test your code!) Due Tuesday at the start of class Late assignments will received reduced credit


Download ppt "Data Representation – Chapter 3 Section 3-1. Terminology “Digital” –Discrete, well defined values/steps –Opposite of analog –Analogy: digital is to analog."

Similar presentations


Ads by Google