Presentation is loading. Please wait.

Presentation is loading. Please wait.

Representation of data types. Introduction We are going to look at representing cardinal numbers, integers and real numbers in decimal, binary, octal.

Similar presentations


Presentation on theme: "Representation of data types. Introduction We are going to look at representing cardinal numbers, integers and real numbers in decimal, binary, octal."— Presentation transcript:

1 Representation of data types

2 Introduction We are going to look at representing cardinal numbers, integers and real numbers in decimal, binary, octal and hexadecimal. What do you already know ?

3 Overview Cardinal, integer and real data types Decimal representation Binary representation Alternative representation Exercises

4 Vocabulary Cardinal number Integer Real number Decimal Binary Octal Hexadecimal A positive whole number Any whole number Any fractional number Base 10 number system Base 2 number system Base 8 number system Base 16 number system

5 Cardinals, integers and reals Cardinal numbers are “counting numbers”. They form the series 0, 1, 2,…  Integers are “all whole numbers”. Cardinal numbers are a subset of integers. They form the series - ,… -1, 0, 1,…  Reals are numbers which include fractional values. There are an infinite number of real numbers between any two numbers.

6 Decimal numbers Based on the number of fingers we have – “digits”. Each digit represents some amount. Each digit can hold one numeral from 0 – 9. To represent numbers greater than 9, more digits must be used. Each digit has a place value which is a power of 10. The value of a number is the sum of the value of each digit multiplied by the place value of the digit. Fractional values are indicated by using a decimal point.

7 Binary numbers Digital devices represent numbers using only two binary digits (bits), 0 & 1. Electronic media use the flow of electricity to represent value: off / on, low / high voltage. Magnetic media use magnetised / unmagnetised “spots”. Optical media use pulses of light.

8 Number representation using binary Each bit can hold one numeral, either 0 or 1. To represent numbers greater than one, more bits need to be used. Each bit has a place value which is a power of 2. The value of a number is the sum of the value of each bit multiplied by the place value of the bit.

9 Cardinals are represented by a number of bits. The maximum magnitude of the number that can be represented by a number of bits equals n 2 -1, where n is the number of bits. Integers are also represented by a number of bits. One bit is the sign bit and the remaining bits are the modulus. A method called “twos complement” is used to determine the value of the number. Reals are represented like integers, with the incorporation of a “binary point”.

10 Real numbers have part of the modulus as integer values and part as fractional values. Fixed point notation as a set number of bits for integers and a set number for fractions. This limits the accuracy of number representation. Floating point notation varies the position of the binary point using an exponent, in the same way as decimal scientific notation. This allows more accurate number representation at the expense of magnitude and vice versa.

11 Octal Long strings of bits are cumbersome, so more convenient alternatives are needed. Octal is base-8, so each octal digit replaces 3 bits, but is easy to convert back to binary. However, splitting 8 bits (1 byte) into groups of three bits is inefficient and so octal is uncommon in modern practice.

12 Hexadecimal Hexadecimal is base-16 and uses A, B, C, D, E and F as numerals. Each hex digit replaces 4 bits, so 2 hex digits replace one byte. A file displayed as hex code will only be ¼ the apparent size of the same file displayed as binary. Hex is much easier to work with than raw binary.

13 Summary Differences between numeric data types Cardinal numbers Integer numbers Real numbers Different methods of representation Decimal Binary Octal Hexadecimal


Download ppt "Representation of data types. Introduction We are going to look at representing cardinal numbers, integers and real numbers in decimal, binary, octal."

Similar presentations


Ads by Google