Coding Theory. Networks and Embedded Software. Digital Circuits. by Wolfgang Neff

Similar documents
1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes

Data Representation and Binary Arithmetic. Lecture 2

Chapter 2 Number System

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

Chapter 3. Information Representation

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

Fundamentals of Programming (C)

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013

ASCII Code - The extended ASCII table

Number System (Different Ways To Say How Many) Fall 2016

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations

Fundamentals of Programming

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

Number Systems Base r

Chapter 2 Bits, Data Types, and Operations

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Oberon Data Types. Matteo Corti. December 5, 2001

Source coding and compression

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme

Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Under the Hood: Data Representation. Computer Science 104 Lecture 2

Bits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Positional Number System

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

OOstaExcel.ir. J. Abbasi Syooki. HTML Number. Device Control 1 (oft. XON) Device Control 3 (oft. Negative Acknowledgement

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

Chapter 2 Bits, Data Types, and Operations

Chemistry Hour Exam 2

Chapter 2 Bits, Data Types, and Operations

Number Representations

5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital

3.1. Unit 3. Binary Representation

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

MACHINE LEVEL REPRESENTATION OF DATA

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example

EE 109 Unit 2. Binary Representation Systems

Inf2C - Computer Systems Lecture 2 Data Representation

The Binary Number System

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

ASSIGNMENT 5 TIPS AND TRICKS

CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation

EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

UTF and Turkish. İstinye University. Representing Text

Fundamental Data Types

EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

Representing Characters and Text

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Simple Data Types in C. Alan L. Cox

Digital Fundamentals

CHW 261: Logic Design

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

Number System. Introduction. Decimal Numbers

Module 2: Computer Arithmetic

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

COMP2611: Computer Organization. Data Representation

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

COMP2121: Microprocessors and Interfacing. Number Systems

Chapter 7. Binary, octal and hexadecimal numbers

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.

BINARY SYSTEM. Binary system is used in digital systems because it is:

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

Do not start the test until instructed to do so!

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

J2 LCM Customer Display. Manual

COMP Overview of Tutorial #2

void mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }

UNIT 7A Data Representation: Numbers and Text. Digital Data

Imperial College London Department of Computing

Hardware. ( Not so hard really )

CS341 *** TURN OFF ALL CELLPHONES *** Practice NAME

Representing Things With Bits

Chapter 2. Data Representation in Computer Systems

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Digital Representation

Do not start the test until instructed to do so!

Chapter 8. Characters and Strings

Introduction to Informatics

PJ-600 Series Printer ESC/P Command Reference

Variables and data types

Representing Characters, Strings and Text

Chapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2

Do not start the test until instructed to do so!

AutoLISP Module 6 Competency Test No.1

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Data Representations & Arithmetic Operations

Transcription:

Coding Theory Networks and Embedded Software Digital Circuits by Wolfgang Neff

Coding (1) Basic concepts Information Knowledge about something Abstract concept (just in mind, can not be touched) Data Representation of information Signals on a medium (characters on paper) Coding Write down information Tree 01.02.2015 Coding Theory, W. Neff 2

Coding (2) Coding and communication are related Message Sender Encoding Channel Decoding Receiver Signal via Medium (e. g. Speech) 01.02.2015 Coding Theory, W. Neff 3

Coding (3) Coding and computer science are related IPO Model Input Encoding Processing Decoding Output Storage Input Encoding Processing Decoding Output 01.02.2015 Coding Theory, W. Neff 4

Coding (4) Coding maps the elements of two sets A := {,, } B:= {Car, Tree, House} Car Tree House Information Representation 01.02.2015 Coding Theory, W. Neff 5

Coding (5) Computers represent information by numbers 0 1 2 Information Number 01.02.2015 Coding Theory, W. Neff 6

Coding (6) Example A door has the three states open, closed, locked The house has four doors We will code the state of the doors of the house Binary coding of the states of a door Hot one coding of the state of a door Binary coding of the state of the house I IV II III 01.02.2015 Coding Theory, W. Neff 7

Coding (7) Binary coding of the states of a door We need two bits to encode the state of the door State First bit Second Bit Open 0 0 Close 0 1 Locked 1 0 Unused 1 1 We need eight bits for the state of the house Door 1 Door 2 Door 3 Door 4 0 0 0 1 1 0 1 0 01.02.2015 Coding Theory, W. Neff 8

Coding (8) Hot one coding of the state of a door We use one bit per state of the door State First bit Second Bit Third Bit Open 0 0 1 Close 0 1 0 Locked 1 0 0 We need twelve bits for the state of the house Door 1 Door 2 Door 3 Door 4 0 0 1 0 1 0 1 0 0 1 0 0 01.02.2015 Coding Theory, W. Neff 9

Coding (9) Direct coding A door has three states O: open C: closed L: locked Our house has 3 4 = 81 states We need seven bits to encode all states 2 7 > 81 There are many don tcare terms n Door I Door II Door III Door IV 0 O O O O 1 O O O C 2 O O O L 3 O O C O 4 O O C C 5 O O C L 6 O O L O 7 O O L C 8 O O L L 9 O C O O 01.02.2015 Coding Theory, W. Neff 10

Numeral Systems (1) Numeral systems encode numbers IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII Information 25 5 10 Decimal Representation XXV V X 五 二十五 十 Roman Representation Chinese Representation 01.02.2015 Coding Theory, W. Neff 11

Numeral Systems (2) Example: Decimal System Base: 10 (number of digits) Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The value of a digit depends on its position Example 2012 dec = 2 10 3 + 0 10 2 + 1 10 1 + 2 10 0 2012 dec = 2 1000 + 0 100 + 1 10 + 2 1 2012 dec = 2012 val (value) 01.02.2015 Coding Theory, W. Neff 12

Numeral Systems (3) Values of numeral representation in general a n a n 1 a 1 a 0 = n i=0 a i b i a i : the digit at position i b: the number of digits Example 3 2012 dec = i=0 a i 10 i = 2 10 3 + 0 10 2 + 1 10 1 + 2 10 0 01.02.2015 Coding Theory, W. Neff 13

Numeral Systems (4) Basic concepts Base: number of digits 10 (we use the decimal system as example) Digits: representation of the digits 0,1,2,3,4,5,6,7,8,9 Value of a representation 2012 dec = 2 10 3 + 0 10 2 + 1 10 1 + 2 10 0 = 2012 val Range: number of possible values = blength of number 4 digits (0 9999) = 10 4 different values 01.02.2015 Coding Theory, W. Neff 14

Numeral Systems (5) Basic concepts (continued) Representation 2012 val = 2012 10 = 201 remainder 2 201 10 = 20 remainder 1 20 10 = 2 remainder 0 2 10 = 0 remainder 2 Reading Direction The algorithm ends here A value of 2012 is represented by 2012 dec 01.02.2015 Coding Theory, W. Neff 15

Numeral Systems (6) The hexadecimal system Base: 16 Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Value 2012 hex = 2 16 3 + 0 16 2 + 1 16 1 + 2 16 0 2 4096 + 0 256 + 1 16 + 2 1 8210 val Range 4 digits (0 FFFF hex ) = 16 4 (65536) different values 01.02.2015 Coding Theory, W. Neff 16

Numeral Systems (7) The hexadecimal system (continued) Representation 2012 val = 2012 16 = 125 remainder 12 (C) 125 16 = 7 remainder 13 (D) 7 16 = 0 remainder 7 A value of 2012 is represented by 7DC hex 01.02.2015 Coding Theory, W. Neff 17

Numeral Systems (8) The binary system Base: 2 Digits: 0,1 Value 1011 bin = 1 2 3 + 0 2 2 + 1 2 1 + 1 2 0 2 8 + 0 4 + 1 2 + 2 1 11 val Range 4 digits (0 1111 bin ) = 2 4 (16) different values 01.02.2015 Coding Theory, W. Neff 18

Numeral Systems (9) The binary system (continued) Representation 57 val = 57 2 = 28 remainder 1 28 2 = 14 remainder 0 14 2 = 7 remainder 0 7 2 = 3 remainder 1 3 2 = 1 remainder 1 1 2 = 0 remainder 1 A value of 57 is represented by 111001 bin 01.02.2015 Coding Theory, W. Neff 19

Binary Numbers (1) Computers use the binary system Because they are digital circuits Therefore they are based on Boolean algebra The binary digits are called bits Some groups of bits have special names Nibble (4 bits), byte (8 bits), word (16 bits or more) Data is encoded as binary numbers Numbers, text, images etc. 01.02.2015 Coding Theory, W. Neff 20

Binary Numbers (2) Fixed-length binary numbers The length of binary numbers is limited The first and the last digit have a name Rightmost bit: LSB (Least Significant Bit 2 0 =1) Leftmost bit: MSB (Most Significant Bit 2 7 =128) Bit 7 6 5 4 3 2 1 0 Value 128 64 32 16 8 4 2 1 Number 1 1 1 0 1 0 0 1 MSB LSB 01.02.2015 Coding Theory, W. Neff 21

Binary Numbers (3) Use exponential calculus to get the range 8 Bits: 2 8 = 256 values Range is 0 255 16 Bits: 2 16 = 2 10+6 = 2 10 2 6 1000*64 64000 2 16 = 65536 Range is 0 65535 32 Bits: 2 32 = 2 10+10+10+2 = 2 10 2 10 2 10 2 2 1000*1000*1000*4 4,000,000,000 2 32 = 4,294,967,296 01.02.2015 Coding Theory, W. Neff 22

Binary Numbers (4) Nibbles (4 bits) can easily converted to hex Examples 0000 0 0100 4 1000 8 1100 C 0001 1 0101 5 1001 9 1101 D 0010 2 0110 6 1010 A 1110 E 0011 3 0111 7 1011 B 1111 F 0000 0000 bin 00 hex 1011 1100 bin BC hex 0110 0100 bin 64 hex 1111 1111 bin FF hex 01.02.2015 Coding Theory, W. Neff 23

Binary Numbers (5) Base64 coding uses 64 digits Used in internet communication Three bytes are encoded in four ASCII chars 1 st Byte 2 nd Byte 3 rd Byte 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 5 4 3 2 1 0 5 4 3 2 1 0 5 4 3 2 1 0 5 4 3 2 1 0 1 st Character 2 nd Character 3 rd Character 4 th Character 01.02.2015 Coding Theory, W. Neff 24

Binary Numbers (6) The coding table of Base64 00 A 08 I 10 Q 18 Y 20 g 28 o 30 w 38 4 01 B 09 J 11 R 19 Z 21 h 29 p 31 x 39 5 02 C 0A K 12 S 1A a 22 i 2A q 32 y 3A 6 03 D 0B L 13 T 1B b 23 j 2B r 33 z 3B 7 04 E 0C M 14 U 1C c 24 k 2C s 34 0 3C 8 05 F 0D N 15 V 1D d 25 l 2D t 35 1 3D 9 06 G 0E O 16 W 1E e 26 m 2E u 36 2 3E + 07 H 0F P 17 X 1F f 27 n 2F v 37 3 3F / 01.02.2015 Coding Theory, W. Neff 25

Binary Numbers (7) Rapid conversion Bin Dec Write 1 above the LSB. Double until MSB is reached. Add all values where the digit is 1. Example: 128 64 32 16 8 4 2 1 1 0 1 1 0 0 1 1 1011 0011 bin = 128+32+16+2+1 = 179 dec 01.02.2015 Coding Theory, W. Neff 26

Binary Numbers (8) Rapid Conversion Dec Bin Double 1 until it is greater than the number to convert. Try to subtract these values. If it is possible the digit is 1 otherwise it is 0. Example: 179 dec = 10110011 bin 179 179 51 51 19 3 3 3 1 256 128 64 32 16 8 4 2 1 0 1 0 1 1 0 0 1 1 01.02.2015 Coding Theory, W. Neff 27

Calculus (1) Binary Addition Same method as decimal addition Noteworthy facts: Leading Zeros Carry Overflow 1 st Number 1 9 4 5 2 nd Number 0 5 1 2 Carry 1 0 0 0 Result 2 4 5 7 Carry Leading Zero No Overflow 01.02.2015 Coding Theory, W. Neff 28

Calculus (2) Binary Addition Example Leading Zero Fixed bit length Bit Flag 7 6 5 4 3 2 1 0 1 st Number 1 1 1 0 0 0 0 0 2 nd Number 0 1 1 1 1 1 0 0 Carry 1 1 1 0 0 0 0 0 0 Result 0 1 0 1 1 1 0 0 Carry An overflow is stored in the carry flag 01.02.2015 Coding Theory, W. Neff 29

Calculus (3) Binary Addition We encounter the following situations 1 st Bit 0 0 1 1 0 0 1 1 2 nd Bit 0 1 0 1 0 1 0 1 Carry 0 0 0 0 1 1 1 1 Result dec 0 1 1 2 1 2 2 3 bin 0 0 0 1 0 1 1 0 0 1 1 0 1 0 1 1 Carry Result 01.02.2015 Coding Theory, W. Neff 30

Calculus (4) Binary Subtraction Subtraction works with borrowing Borrowed from next bit 1 st Bit bin 0 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 dec 0 1 2 1 2 1 2 3 2 nd Bit 0 0 1 1 0 0 1 1 Borrow 0 0 0 0 1 1 1 1 Result 0 1 1 0 1 0 0 1 01.02.2015 Coding Theory, W. Neff 31

Calculus (5) Binary Multiplication Same method as decimal multiplication Example: 13*5 = 65 = 1000001 bin 1 1 0 1 * 1 0 1 1 1 0 1 + 0 0 0 0 + 1 1 0 1 1 0 0 0 0 0 1 01.02.2015 Coding Theory, W. Neff 32

Calculus (6) Shifting A left shift doubles the value of the number 0 0 0 0 0 1 0 1 5*2 = 10 Left Shift 0 0 0 0 1 0 1 0 A right shift halves the value of the number 10 / 2 = 5 0 0 0 0 1 0 1 0 Right Shift 0 0 0 0 0 1 0 1 01.02.2015 Coding Theory, W. Neff 33

Calculus (6) Binary Division Same method as decimal division. Sometimes replaced by shifting because of speed. Example: 2,54*15 = 254*15/100 = 38 Multiply with an appropriate power of two (2 7 =128) 2,54 = 2,54*2 7 / 2 7 = 325 / 2 7 Multiply with numerator and then shift 2,54*15 = 325*15 / 2 7 = 4875 / 2 7 = 4875 >> 7 = 38 This is only an approximation but may be very fast» 254/100 = 2,540 vs. 325/128 = 2,539» E. g. AVR: with division 250 cycles vs. 16 cycles with shift 01.02.2015 Coding Theory, W. Neff 34

Signed Numbers (1) Fixed-length binary numbers have a range. If we exceed the range we restart from zero. Therefore the number ray becomes a circle. length = 3 bits 01.02.2015 Coding Theory, W. Neff 35

Signed Numbers (2) We get negative numbers if we go beyond zero. 2 n numbers 2 n-1 numbers 2 n-1 numbers 01.02.2015 Coding Theory, W. Neff 36

Signed Numbers (3) We have to sacrifice positive numbers to get negative numbers. Negative numbers have its MSB is set. The range of negative number is Positive number range: 0...2 n-1-1 Negative number range: -1...-2 n-1 n: bit length of number 01.02.2015 Coding Theory, W. Neff 37

Signed Numbers (4) Two s complement Used to negate a number Complement all bits Add a value of one Number 0 0 0 1 1 0 0 0 Complement 1 1 1 0 0 1 1 1 +1 0 0 0 0 0 0 0 1 Carry 0 0 0 0 1 1 1 0 Result 1 1 1 0 1 0 0 0 01.02.2015 Coding Theory, W. Neff 38

Signed Numbers (5) Rapid conversion Bin signed Dec Negate the MSB Add the rest Example: B3 hex = -77 dec 128 64 32 16 8 4 2 1 1 0 1 1 0 0 1 1 10110011 bin = -128+32+16+2+1 = -77 dec 01.02.2015 Coding Theory, W. Neff 39

Signed Numbers (6) Rapid conversion negative Dec Bin Add number to range Convert result to binary Example: -77 dec = B3 hex Bit length = 8 Range: 2 8 = 256 256 77 = 179 179 dec = 10110011 bin = B3 hex 01.02.2015 Coding Theory, W. Neff 40

Fixed-Point Numbers (1) Fixed-point numbers are numeral systems with a negative index: a n a n 1 a 1 a 0. a 1 a m = n i= m a i b i There are m positions after the decimal point There are n+1 positions before the decimal point 01.02.2015 Coding Theory, W. Neff 41

Fixed-Point Numbers (2) Example: a base 16 fixed-point number Number: 20.12 hex Value: 20.12 hex = 2 16 1 + 0 16 0 + 1 16-1 + 2 16-2 2 16 + 0 1 + 1 1 / 16 + 2 1 / 256 2 16 + 0 1 + 1 0.0625 + 2 0.00390625 32.0703125 You have to round to preserve the number of positions after the decimal point. 01.02.2015 Coding Theory, W. Neff 42

Fixed-Point Numbers (2) Example: a base 16 fixed-point number Representation 32.07 = 32 + 0.07 32 = 20 hex Division by 1 / 16 0.07 = 0.07 16 = 1 remainder 0.12 0.12 16 = 1 remainder 0.92 0.92 16 = 14 remainder 0.72 0.72 16 = 11 remainder 0.52 Stop when you have got enough positions The value of 32.07 is 20.11EB hex Round-off errors are almost inevitable Reading Direction 01.02.2015 Coding Theory, W. Neff 43

Fixed-Point Numbers (3) Binary fixed-point numbers Notation of binary fractional numbers s(n.m): signed binary fractional - n bits before the decimal point and m bits after. MSB is sign bit. u(n.m): unsigned binary fractional n bits before the decimal point and m bits after it. No sign bit. Binary fractional calculus d(n.m) + d(n.m) = d(n+1.m) = d(n.m) and carry flag d(n 1.m 1 ) d(n 2.m 2 ) = d(n 1 +n 2.m 1 +m 2 ) 01.02.2015 Coding Theory, W. Neff 44

Fixed-Point Numbers (4) d(1.n) binary fractional numbers often used in digital signal processing (DSP) Multiplication modifies the number format d(1.n) d(1.n) = d(2.2 n) A left shift is necessary to obtain d(1.2 n+1) An overflow might occur indicated by the carry flag Some microcontroller have special instructions AVR: FMUL Fractional Multiply Unsigned s(1.7) s(1.7) s(1.15) 01.02.2015 Coding Theory, W. Neff 45

Fixed-Point Numbers (5) Rapid conversion d(n,m) Dec Start with 1 at the decimal point. Double it until you reach the MSB. Half it until you reach the LSB. Example: 10110011 s(1.7) = B3 s(1.7) -1 1 / 2 1 / 4 1 / 8 1 / 16 1 / 32 1 / 64 1 / 128 1 0 1 1 0 0 1 1 B3 s(1.7) = -1+ 1 / 4 + 1 / 8 + 1 / 64 + 1 / 128 = -0.6015625 dec 01.02.2015 Coding Theory, W. Neff 46

Fixed-Point Numbers (6) Rapid Conversion Dec Bin Choose a binary fractional format and write its values above the positions. Try to subtract these values. If it is possible then the digit is 1 otherwise it is 0. Example: -0.60 dec = 10110011 s(1.7) -0.6 0.4 0.4 0.15 0.025 0.025 0.025 0.009375-1 1 / 2 1 / 4 1 / 8 1 / 16 1 / 32 1 / 64 1 / 128 1 0 1 1 0 0 1 1 01.02.2015 Coding Theory, W. Neff 47

Fixed-Point Numbers (7) Example: sin(0 2π) in s(1.7) fractional binaries n 0 1 2 3 4 5 6 7 x 0,00 0.039 0.79 1.18 1.157 1.196 2.36 2.75 sin(x) 0.00 0.38 0.71 0.92 1.00 0.92 0.71 0.38 s(1.7) 00 hex 30 hex 5A hex 76 hex 7F hex 76 hex 5A hex 30 hex 1.0 is not in the range of s(1.7). We use 7E instead. This is called saturation. n 8 9 10 11 12 13 14 15 x 3.14 3.53 3.93 4.32 4.71 5.11 5.50 5.89 sin(x) 0.00-0.38-0.71-0.92-1.00-0.92-0.71-0.38 s(1.7) 00 hex CF hex A5 hex 89 hex 80 hex 89 hex A5 hex CF hex 01.02.2015 Coding Theory, W. Neff 48

Floating-Point Numbers (1) Do not have a fixed decimal point position. Are expressed by a mantissa and an exponent. Are usually normalized: Only one digit before the decimal point 20.12 dec 2.012 dec 10 1 (normalized) Floating-point numbers are standardized: IEEE 754: Standard for Floating-Point Arithmetic Commonly used: single and double precision 01.02.2015 Coding Theory, W. Neff 49

Floating-Point Numbers (2) IEEE 754 floating-point binary numbers Format of a half precision floating-point 1 st Byte 2 nd Byte S C C C C C F F F F F F F F F F Sign Character Fraction Value of a half precision floating-point = (-1) S Mantissa 2 Exponent Bias = 15 Exponent = Character Bias (-14 +15) Character 00000 and 11111 reserved for ± and NaN (Not a Number) Mantissa = 1.Fraction bin 01.02.2015 Coding Theory, W. Neff 50

Floating-Point Numbers (3) Example: value of half precision B248 hex Value: 1 st Byte 2 nd Byte S C C C C C F F F F F F F F F F 1 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 Exponent = Character - Bias = 16 15 = 1 Mantissa = 1. + Fraction = 1.1001001000 = 1,5703125 Value = (-1) S Mantissa 2 Exponent = -1 1,141571 2 Half precision B248 hex = -3.140625 dec 01.02.2015 Coding Theory, W. Neff 51

Floating-Point Numbers (4) Example: π as a half precision binary number Representation 3.14159 = 11.00100100001111 bin 1.100100100001111 bin 2 1 Character = Exponent + Bias = 1 + 15 = 16 = 10000 bin Fraction = 1001001000 bin 1 st Byte 2 nd Byte S C C C C C F F F F F F F F F F 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 π = 4248 hex represented as a half precision binary 01.02.2015 Coding Theory, W. Neff 52

Floating-Point Numbers (5) Characteristics of IEEE 754 floating-points Characteristic Half precision Single precision Double precision Size 16 bit 32 bit 64 bit Character 5 bit 8 bit 11 bit Fraction 10 bit 23 bit 52 bit Exponent -14 15-126 127-1022 1023 Bias 15 127 1023 01.02.2015 Coding Theory, W. Neff 53

Characters (1) Characters are mapped to codes and fonts. 5 25 105 10 Coding C A Ä ð B A B C Ä A B Fonts Fonts describe the graphic appearance of characters Character C 01.02.2015 Coding Theory, W. Neff 54

Characters (2) Characters are encoded by numbers. Characters are displayed by fonts. The mapping need not be total. There can be characters without code There can be characters not present in a font There are many different fonts. Times New Roman Harlow Solid Italic 01.02.2015 Coding Theory, W. Neff 55

Characters (3) ASCII: the ancestor American Standard Code for Information Interchange Published by ASA in 1963 Uses 7 bits per character Contains Control characters Letters and Numbers Punctuation and special characters 01.02.2015 Coding Theory, W. Neff 56

Characters (4) The ASCII code table ASCII Lower Hex Digit 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 NUL SOH STX ETX EOF ENQ ACK BEL BS HT LF VT FF CR SO SI Higher Hex Digit 1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 2! " # $ % & ' ( ) * +, -. / 3 0 1 2 3 4 5 6 7 8 9 : ; < = >? 4 @ A B C D E F G H I J K L M N O 5 P Q R S T U V W X Y Z [ \ ] ^ _ 6 ` a b c d e f g h i j k l m n o 7 p q r s t u v w x y z { } ~ DEL 01.02.2015 Coding Theory, W. Neff 57

Characters (5) Latin-1: One nation one character set Deficiencies of ASCII Suitable for English, only Other languages use additional symbols Only 7 bits of a byte used ISO 8859 Uses all 8 bits of a byte for coding 128 additional symbols One standard per region -1: Western European -2: Central European -7: Latin/Greek -11: Latin/Thai 01.02.2015 Coding Theory, W. Neff 58

Characters (6) The ISO 8859-1 code table: Latin 1 Latin Higher Hex Digit 8 9 Lower Hex Digit 0 1 2 3 4 5 6 7 8 9 A B C D E F same as ASCII unused A NBSP ª «B ± ² ³ µ ¹ º» ¼ ½ ¾ C À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï D Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Þ ß E à á â ã ä å æ ç è é ê ë ì í î ï F ð ñ ò ó ô õ ö ø ù ú û ü ý þ ÿ 01.02.2015 Coding Theory, W. Neff 59

Characters (7) Unicode: One code for all nations Consistent encoding of all writing system Comprises modern and historic scripts Consists of more than 110 000 characters Uses 32 bits for coding Standardized as ISO/IEC 10646 Special formats for storage (UTF) 01.02.2015 Coding Theory, W. Neff 60

Characters (8) Unicode is or organized in planes. Diacritics and Ligatures à, å, ä, æ Non-Latin writing systems العربية Arabic: Logographic writing system Chinese: 汉语 Special purpose characters Mathematics:,,,, ±,, 01.02.2015 Coding Theory, W. Neff 61

Characters (9) Example: Greek and Coptic (U+0370-U+03FF) Code 0 1 2 3 4 5 6 7 039 ΐ Α Β Γ Δ Ε Ζ Η U+0390: ΐ Greek small litter iota with U+0391: Α Greek capital letter alpha U+0392: Β Greek capital letter beta U+0393: Γ Greek capital letter gamma U+0394: Δ Greek capital letter delta 01.02.2015 Coding Theory, W. Neff 62

Characters (10) Unicode Transformation Format Used to store and process Unicode characters UTF-16 Used in Windows, OS X, Java,.Net UTF-8 Used to store Unicode characters in files Aims to reduce the size of Unicode files Variable length 8 bit code ASCII files are valid UTF-8 files 01.02.2015 Coding Theory, W. Neff 63

Characters (11) UTF-8 Coding procedure Unicode Character U+ xxxx xyyy yzzz zzzz If each x and each y is 0 The code is 0zzz zzzz (n. b. this is the ASCI code) If each x is 0 The code is 110y yyyz 10zz zzzz Otherwise The code is 1110 xxxx 10xy yyyz 10zz zzzz 01.02.2015 Coding Theory, W. Neff 64

Characters (12) UTF-8 Coding examples y U+0079 00000 0000 1111001 Each x and each y is 0 y 01111001 ä U+00E4 00000 0001 1100100 Each x is 0 ä 11000011 10100100 U+20AC 00100 0001 0101100 11100010 10000010 10101100 01.02.2015 Coding Theory, W. Neff 65

Important Expressions (1) numbering system digit range decimal system binary system hexadecimal system bit length MSB / LSB Zahlensystem Ziffer Wertebereich Dezimalsystem Binärsystem Hexadezimalsystem Bitbreite MSB / LSB 01.02.2015 Coding Theory, W. Neff 66

Important Expressions (2) carry leading zero overflow two's Complement floating point number character encoding scheme internationalization (i18n) Übertrag Führende Null Überlauf Zweikomplement Gleitkommazahl Zeichen Kodierungsschema Internationalisierung 01.02.2015 Coding Theory, W. Neff 67