CSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems

Size: px
Start display at page:

Download "CSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems"

Transcription

1 CSC 8400: Computer Systems Represen3ng and Manipula3ng Informa3on Background: Number Systems 1

2 Analog vs. Digital System q Analog Signals - Value varies con1nuously q Digital Signals - Value limited to a finite set - Digital systems more robust q Binary Signals - Has at most 2 values - Used to represent bit values - Bit 1me T needed to send 1 bit Why Bits (Binary Digits)? q Computers are built using digital circuits - Inputs and outputs can have only two values - True (high voltage) or false (low voltage) - Represented as 1 and 0 q Can represent many kinds of informa1on - Boolean (true or false) - Numbers (23, 79, ) - Characters ( a, z, ) - Pixels, sounds - Internet addresses 2

3 Coding q A single binary input can have two values: 1 or 0 q More bits = more combina1ons Coding q How many values can you represent on 3 bits? q What about n bits? 3

4 Binary Numbers q How do you figure out what the value of 1110 is? - Same way you do for 4173, for instance q Decimal (base 10) - Each digit represents a power of = 4 x x x x 10 0 q Binary (base 2) - Each bit represents a power of = 1 x x x x 2 0 = Coun3ng in Binary 0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 =

5 Number Systems Base Character Set 2 {0,1} 3 {0,1,2} 4 {0,1,2,3} 5 {0,1,2,3,4} 6 {0,1,2,3,4,5} 7 {0,1,2,3,4,5,6} 8 {0,1,2,3,4,5,6,7} 9 {0,1,2,3,4,5,6,7,8} 10 {0,1,2,3,4,5,6,7,8,9} 11 {0,1,2,3,4,5,6,7,8,9,A} 12 {0,1,2,3,4,5,6,7,8,9,A,B} 13 {0,1,2,3,4,5,6,7,8,9,A,B,C} 14 {0,1,2,3,4,5,6,7,8,9,A,B,C,D} 15 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E} 16 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} Binary (Base 2) to Decimal q Sum up (bit*weight): Binary Weights = 10? = 10? 5

6 Powers of 2 q Memorize! Yotta Zetta Exa Peta Tera Giga Mega Kilo Y Z E P T G M K Octal (Base 8) to Decimal q Sum up (digit*weight): Octal weights = 10? = 10? 6

7 Hexadecimal (Base 16) to Decimal q Sum up (hex digit*weight): A 2 B 1 4 A 6 Hexadecimal Weight A2B 16 = 10? 14A6 16 = 10? Coun3ng in Octal 0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 =

8 Coun3ng in Hexadecimal 0 = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = 10 = 11 = 12 = 13 = 14 = 15 = 16 = 17 = 18 = A 00 B 00 C 00 D 00 E 00 F Decimal to Binary q Use the Placement Method Powers of = 2? 128 goes into 155 once leaving 27 to be placed 1??????? 64 and 32 are too big (make them 0) 16 goes in once leaving 11 and so on ???? 8

9 You Try It Powers of = 2? Hexadecimal Benefits q It is often convenient to write binary (base-2) numbers as hexadecimal (base-16) numbers instead. - fewer digits -- four bits per hex digit - less error prone -- easy to corrupt long string of 1 s and 0 s Binary Hex Decimal Binary Hex Decimal A B C D E F 15 9

10 Converting from Binary to Hexadecimal q Every four bits is a hex digit. - start grouping from right-hand side A 8 F 4 D 7 This is not a new machine representation, just a convenient way to write the number. Exercises 1. Convert the hex value 0x7A8BF7D6 into its binary equivalent: 7 A 8 B F 7 D Convert the binary to hex: E 9 4 C 5 F 10

11 Exercises (contd.) 3. Convert from binary to octal: Number Systems q The binary, hexadecimal (hex) and octal system share one common feature they are all based on powers of 2. q Each digit in the hex system is equivalent to a four- digit binary number and each digit in the octal system is equivalent to a 3- digit binary number. 11

12 Prac3ce Hex Decimal Binary Binary Addi3on q Let s review decimal addi1on - From right to leg, we add each pair of digits - We write the sum, and add the carry to the next column Sum Carry

13 Binary Addi3on q From right to leg, we add each pair of bits = = = = 10 q We write the sum, and add the carry to the next column Base 10 Base Sum Carry Sum Carry Data Representa3on 13

14 What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings, - Images pixels, colors, shapes, - Sound - Logical true, false - Instructions - q Data type: - representation and operations within the computer Word-Oriented Memory Organization q Addresses Specify Byte Locations - Address of first byte in word - Addresses of successive words differ by 4 (32-bit) or 8 (64-bit) 32-bit 64-bit Words Words Bytes Addr. Addr = 0000?? Addr = 0004?? Addr = 0008?? Addr = 0012?? Addr = 0000?? Addr = 0008??

15 Data Representations q Sizes of C Objects (in Bytes) C Data Type Sparc/Unix Typical 32-bit Intel IA32 int long int char short float double long double /12 char * (or any other pointer) Address vs. Value q Sometimes we want to deal with the address of a memory location, rather than the value it contains. address value q Adding a column of numbers. - R2 contains address of first location. - Read value, add to sum, and increment R2 until all numbers have been processed. q R2 is a pointer -- it contains the address of data we re interested in. R2 x3100 x3107 x2819 x0110 x0310 x0100 x1110 x11b1 x0019 x3100 x3101 x3102 x3103 x3104 x3105 x3106 x

16 Byte Ordering q How should bytes within multi-byte word be ordered in memory? q Conventions - Sun, Mac are Big Endian machines o Least significant byte has highest address - Alpha, PC are Little Endian machines o Least significant byte has lowest address Byte Ordering Example q Big Endian - Least significant byte has highest address q Little Endian - Least significant byte has lowest address q Example - Variable x has 4-byte representation 0x Address given by &x is 0x100 Big Endian Little Endian 0x100 0x101 0x102 0x x100 0x101 0x102 0x

17 Integers Unsigned Integers q An n-bit unsigned integer represents 2 n values: from 0 to 2 n

18 Signed Integers q How do computers differen1ate between posi1ve and nega1ve integers? - Posi1ve integers have most significant bit 0 - Nega1ve integers have most significant bit 1 q Nega1ve integer representa1ons: 1. Sign Magnitude 2. One s Complement 3. Two s Complement 1. Sign Magnitude q Use the legmost bit to store the sign - Zero for posi1ve number - One for nega1ve number q Examples è è -44 Sign Magnitude q Hard to do arithme1c this way, so it is rarely used - What is the result of 44 44? 18

19 1. Sign Magnitude (contd.) è è -44 Sign Magnitude q For numbers represented on n bits: - Range of posi1ve integers: from 0 to (2 n-1 1) - Range of nega1ve integers: from (2 n-1 1) to 1 2. One s Complement q Legmost bit is 0 for posi1ve numbers è 44 q To obtain the corresponding nega1ve number (- 44), flip every bit: è -44 q So - 44 is the one s complement of

20 2. One s Complement (contd.) q What is the result of 44 44? ( 44) (-44) q Issue: two different representa1ons for zero 3. Two s Complement q Legmost bit is 0 for posi1ve numbers è 44 q To obtain the corresponding nega1ve number - 44, add 1 to the one s complement of 44: è one s complement è two s complement 20

21 3. Two s Complement (contd.) q What is the result of 44 44? ( 44) (-44) q Used by most computer systems q For numbers represented on n bits: - Range of posi1ve integers: - Range of nega1ve integers: from 0 to (2 n-1 1) from (2 n-1 1) to 1 Converting Two s Complement to Decimal 1. If leading bit is one, take two s complement to get a positive number. 2. Add powers of 2 that have 1 in the corresponding bit positions. 3. If original number was negative, add a minus sign. X = two = = = 104 ten Assuming 8-bit 2 s complement numbers. n 2 n

22 More Examples X = two = = = 39 ten X = two -X = = = = 26 ten X = -26 ten n 2 n Assuming 8-bit 2 s complement numbers. Two s Complement Signed Integers q Most significant bit is sign bit and has weight 2 n-1. q Range of an n-bit number: -2 n-1 through 2 n The most negative number (-2 n-1 ) has no positive counterpart

23 Number Representa3ons Review q Legmost bit zero indicates q Sign Magnitude: - nega1ve values q One s Complement: - nega1ve values q Two s complement: - nega1ve values positive number most significant bit 1 has weight 0 are the 1 s complement of positive values (flip every bit) are the 2 s complement of positive values most significant bit 1 has weight 2 n-1 Fill in the Table Bit Pattern Value (Sign Magnitude) Value (One s Complement) Value (Two s Complement)

24 Ques3on q What value does represent? ASCII American Standard Code for Informa3on Interchange 24

25 The ASCII Code American Standard Code for Information Interchange NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI 16 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 32 SP! " # $ % & ' ( ) * +, -. / : ; < = >? A B C D E F G H I J K L M N O 80 P Q R S T U V W X Y Z [ \ ] ^ _ 96 ` a b c d e f g h i j k l m n o 112 p q r s t u v w x y z { } ~ DEL Lower case: and upper case: E.g., a is 97 and A is 65 (i.e., 32 apart) char Constants q C has char constants (sort of) q Examples Constant Binary Representation (assuming ASCII) Note 'a' letter '0' digit '\x61' hexadecimal form Use single quotes for char constant Use double quotes for string constant * Technically 'a' is of type int; automatically truncated to type char when appropriate 25

26 More char Constants Escape characters Constant Binary Representation (assuming ASCII) Note '\a' alert (bell) '\b' backspace '\f' form feed '\n' newline '\r' carriage return '\t' horizontal tab '\v' vertical tab '\\' backslash '\?' question mark '\'' single quote '\"' double quote '\0' null Used often Interesting Properties of ASCII Code q What is relationship between a decimal digit ('0', '1', ) and its ASCII code? q What is the difference between an upper-case letter ('A', 'B', ) and its lower-case equivalent ('a', 'b', )? q Given two ASCII characters, how do we tell which comes first in alphabetical order? q Are 128 characters enough? ( 26

27 Other Data Types q Floating Points - IEEE representation, to be covered later q Text strings - sequence of characters, terminated with NULL (0) q Image - array of pixels o monochrome: one bit (1/0 = black/white) o color: red, green, blue (RGB) components (e.g., 8 bits each) o other properties: transparency q Sound - sequence of fixed-point numbers Bit- Level Operators (Common to C and Java) 27

28 Used in Networking Used in Encryption/ Decryption 28

29 Used in Compression Look at the DEFLATE algorithm, for instance everything in bits, not bytes Overview of C bit-level operators ~ Bitwise NOT ( flips bits) & Bitwise AND ^ Bitwise XOR Bitwise OR << Bitwise left shift (shifts bits to left) >> Bitwise right shift (shifts bits to right) 29

30 Observation 1 Addition q 2 s comp. addition is just binary addition. - assume all integers have the same number of bits - for now, assume that sum fits in n-bit 2 s comp. representation (104) (-10) (-16) + (-9) (88) (-19) Assuming 8-bit 2 s complement numbers. Observation 2 Sign Extension q To add two numbers, we must represent them with the same number of bits. q If we just pad with zeroes on the left: 4-bit 8-bit 0100 (4) (still 4) 1100 (-4) (12, not -4; NOT GOOD!) q Instead, replicate the MS bit -- the sign bit: 4-bit 8-bit 0100 (4) (still 4) 1100 (-4) (still -4) 30

31 Bit-Level Operations in C q q Operations &,, ~, ^ available in C - Apply to any integral data type o long, int, short, char - View arguments as bit vectors - Arguments applied bit-wise Examples (char data type) - ~0x41 --> 0xBE ~ > ~0x00 --> 0xFF ~ > x69 & 0x55 --> 0x & > x69 0x55 --> 0x7D > Bitwise Operator: NOT (~) q NOT (~) is the same as one s complement - Turns 0 to 1, and 1 to 0 q Examples: - Assume that x is an integer on 8 bits. Set x = 1. What is the value of ~x? 0 1 ~x - Set the least significant bit of y to 0: y = y & ; 31

32 Bitwise Operators: AND (&) and OR (I) Bitwise AND (&) Bitwise OR ( ) & & Bitwise Operators: AND (&) and OR (I) Assume that x is an integer variable. q Determine the least significant bit of x: int bit = x & ; q Set the least significant bit of x to 1: x = x ; 32

33 Bitwise Operator: XOR q XOR (^) - 0 if both bits are the same - 1 if the two bits are different ^ q For an integer x, what is the value of x^x Relations Between Operations q DeMorgan s Laws - Express & in terms of, and vice-versa o A & B = ~(~A ~B) A and B are true if and only if neither A nor B is false o A B = ~(~A & ~B) A or B are true if and only if A and B are not both false q Exclusive-Or using Inclusive Or o A ^ B = (~A & B) (A & ~B) Exactly one of A and B is true o A ^ B = (A B) & ~(A & B) Either A is true, or B is true, but not both 33

34 Bitwise Operator: Le` Shi` q Leg shig: x << y (same as mul1ply by 2 y ) - Shig bit- vector x leg y posi1on - Fill blanks with << Bitwise Operator: Right Shi` q Right shig: x >> y (same as divide by 2 y ) - Shig bit- vector x right y posi1ons - Fill in blanks with sign bit (this is called arithme/c shi0) >>2-75>>2 sign extension sign extension Note: Java also has the unsigned shift operator >>> Not available in C. 34

35 Bitwise Operators q Print all the bits of a character from right to leg (star1ng with the least significant bit): char c = 0xB5; void ReversePrintBits(char c) { /* add code here */ } Bitwise Operators q Print all the bits of a character from leg to right (star1ng with the most significant bit): char c = 0xB5; void PrintBits(char c) { /* add code here */ } 35

36 Bitmasks q Used to change or query one or more bits in a variable. q The bitmask indicates which bits are to be affected. q Common opera1ons: - Set one or more bits (set to 1) - Clear one or more bits (set to zero) - Read one or more bits q Examples: - Set bit 2 of x (bit 0 is least significant): x = x - Clear bit 3 of x: x = x - Read bit 4 of x: bit = x Bitmasks q Set the least significant byte of x to FF: x = x ; q Clear the least significant byte of x: x = x ; q Read the least significant byte of x: byte = x ; 36

37 Bitmasks q Set to 1 bits 2, 4 and 7 of x (0 is least significant): x = x ; q Clear bits 3, 4 and 5 of x: x = x ; Contrast: Logical Operators 37

38 Familiar Operators (common to C, Java) Category Operators Arithmetic ++expr --expr expr++ expr-- expr1*expr2 expr1/expr2 expr1%expr2 expr1+expr2 expr1-expr2 Assignment expr1=expr2 expr1*=expr2 expr1/=expr2 expr1%=expr2 expr1+=expr2 expr1-=expr2 Relational expr1<expr2 expr1<=expr2 expr1>expr2 expr1>=expr2 expr1==expr2 expr1!=expr2 Logical!expr expr1&&expr2 expr1 expr2 Function Call Cast Conditional func(paramlist) (type)expr expr1?expr2:expr3 Logical Operators && (Logical AND), (Logical OR),! (Logical NOT) q Always return 0 or 1 q View 0 as False q Anything nonzero as True q Examples (char data type) -!0x41 --> -!0x00 --> -!!0x41 --> - 0x69 && 0x55 --> - 0x69 0x55 --> 38

39 What is the Output? int a = 0x43, b = 0x21; printf("a b = %x\n", a b); Printf("a b = %x\n", a b); printf("a & b = %x\n", a & b); printf("a && b = %x\n", a && b); Mental Exercise /* * isnotequal - return 0 if x == y, and 1 otherwise * Examples: isnotequal(5,5) = 0, isnotequal(4,5) = 1 */ int isnotequal (int x, int y) { return ; } 39

40 Limits of the Machine: How much memory space for data? Storage Units 1 bit = smallest unit of memory 1 byte = 8 bits 4 bytes = 1 word (system dependent) 40

41 Words q On most machines, bytes are assembled into larger structures called words, where a word is usually defined to be the number of bits the processor can operate on at one 1me. q Some machines use four- byte words (32 bits), while some others use 8- byte words (64 bits) and some machines use less conven1onal sizes. 32-bit 64-bit Words Words Bytes Addr. Addr = 0000?? Addr = 0004?? Addr = 0008?? Addr = 0012?? Addr = 0000?? Addr = 0008?? The sizeof Operator Category sizeof Operators sizeof(type) sizeof(expr) q Unique among operators: evaluated at compile- 1me q Evaluates to type size_t; on tanner, same as unsigned int q Examples int i = 10; double d = 100.0; sizeof(int) /* On tanner, evaluates to 4 */ sizeof(i) /* On tanner, evaluates to 4 */ sizeof(double) /* On tanner, evaluates to 8 */ sizeof(d) /* On tanner, evaluates to 8 */ sizeof(d ) /* On tanner, evaluates to 8 */ 41

42 Determining Data Sizes q To determine data sizes on your computer #include <stdio.h> int main() { printf("char: %d\n", (int)sizeof(char)); printf("short: %d\n", (int)sizeof(short)); printf("int: %d\n", (int)sizeof(int)); printf("long: %d\n", (int)sizeof(long)); printf("float: %d\n", ); printf("double: %d\n", ); printf("long double: %d\n", ); return 0; } q Output on tanner char: 1 short: 2 int: 4 long: 4 float: 4 double: 8 long double: 16 Overflow: Running Out of Room q Adding two large integers together - Sum might be too large to store in available bits - What happens? (8) (-8) (9) (-9) (-15) (+15) Assuming 5-bit 2 s complement numbers. q We have overflow if: - signs of both operands are the same, and - sign of sum is different. 42

43 Overflow q Unsigned integers - All arithme1c is modulo arithme1c - Sum would just wrap around q Signed integers - Can get nonsense values - Example with 16- bit integers o Sum: o Result: Try It Out q Write a program that computes the sum Use only short int variables in your code: short int a = 10000; short int b = 20000; short int c = 20000; short int sum = a + b + c; printf("sum = %d\n", sum); 43

44 Exercise q Assume only four bits are available for represen1ng integers, and signed integers are represented in 2 s complement. q Compute the value of the expression Casting Signed to Unsigned q C Allows Conversions from Signed to Unsigned short int x = 15213; unsigned short int ux = (unsigned short) x; short int y = ; unsigned short int uy = (unsigned short) y; q Resulting Value - No change in bit representation - Nonnegative values unchanged o ux = Negative values change into (large) positive values o uy =

45 Try It Out q C code: char a = 0xFF; unsigned char b = 0xFF; printf("a = %d\n", a); printf("b = %d\n", b); Int to Char? Try It Out #include <stdio.h> int main() { char c = 0x81; int i; } i = c; printf(" integer = %x\n character = %x\n", i, c); i = 0x ; c = i; printf(" integer = %d\n character code = %d\n", i, c); return 0; 45

46 C vs. Java: Cast Conversions q Java: demo1ons are not automa1c C: demo1ons are automa1c int i; char c; i = c; /* Implicit promotion */ /* Sign extension in Java and C */ c = i; /* Implicit demotion */ /* Java: Compiletime error */ /* C: OK; truncation */ c = (char)i; /* Explicit demotion */ /* Truncation in Java and C */ What did we learn? q Computer represents everything in binary - Integers, floa1ng- point numbers, characters, - Pixels, sounds, colors, etc. q Memory is bytes, words, endian, two s complement, ASCII, conver1ng between hex- binary- decimal, binary opera1ons, sign extension, limits of machine, overflow, cast conversions 46

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? CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,

More information

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? CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, S. Rajopadhye Colorado State University How do we represent data

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations Computer is a binary digital system. Digital system: finite number of symbols Binary (base two) system: has two states: 0 and 1 Basic unit of information is the

More information

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers CSC 2400: Computer Systems Bits, Bytes and Data Types 1 Goals for this Week Binary number system Why binary? Converting between decimal and binary and octal and hexadecimal number systems Finite representations

More information

Fundamentals of Programming (C)

Fundamentals of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamentals of Programming (C) Group 8 Lecturer: Vahid Khodabakhshi Lecture Number Systems Department of Computer Engineering Outline Numeral Systems

More information

Data Representation and Binary Arithmetic. Lecture 2

Data Representation and Binary Arithmetic. Lecture 2 Data Representation and Binary Arithmetic Lecture 2 Computer Data Data is stored as binary; 0 s and 1 s Because two-state ( 0 & 1 ) logic elements can be manufactured easily Bit: binary digit (smallest

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 2 Number Systems & Arithmetic Lecturer : Ebrahim Jahandar Some Parts borrowed from slides by IETC1011-Yourk University Common Number Systems System Base Symbols Used

More information

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

Number System (Different Ways To Say How Many) Fall 2016 Number System (Different Ways To Say How Many) Fall 2016 Introduction to Information and Communication Technologies CSD 102 Email: mehwish.fatima@ciitlahore.edu.pk Website: https://sites.google.com/a/ciitlahore.edu.pk/ict/

More information

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

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15

More information

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS Chapter 1. 1.1. INTRODUCTION Digital computers have brought about the information age that we live in today. Computers are important tools because they can locate and process enormous amounts of information

More information

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

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes 1 DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations Other Binary Codes Error Detection Codes 2 Data Types DATA REPRESENTATION Information that a Computer

More information

3.1. Unit 3. Binary Representation

3.1. Unit 3. Binary Representation 3.1 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.2 3.3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based on discrete

More information

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 ICS 2008 Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32-bit Intel IA32 int 4 4 4 long int 8 4 4

More information

Chapter 2 Number System

Chapter 2 Number System Chapter 2 Number System Embedded Systems with ARM Cortext-M Updated: Tuesday, January 16, 2018 What you should know.. Before coming to this class Decimal Binary Octal Hex 0 0000 00 0x0 1 0001 01 0x1 2

More information

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

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL 3. 3. EE 9 Unit 3 Binary Representation Systems ANALOG VS. DIGITAL 3.3 3. Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world

More information

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

Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014 Exercises Software Development I 03 Data Representation Data types, range of values, ernal format, literals October 22nd, 2014 Software Development I Wer term 2013/2014 Priv.-Doz. Dipl.-Ing. Dr. Andreas

More information

Chapter 3. Information Representation

Chapter 3. Information Representation Chapter 3 Information Representation Instruction Set Architecture APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL 3 MICROCODE LEVEL

More information

Number Representations

Number Representations Simple Arithmetic [Arithm Notes] Number representations Signed numbers Sign-magnitude, ones and twos complement Arithmetic Addition, subtraction, negation, overflow MIPS instructions Logic operations MIPS

More information

EE 109 Unit 2. Binary Representation Systems

EE 109 Unit 2. Binary Representation Systems EE 09 Unit 2 Binary Representation Systems ANALOG VS. DIGITAL 2 3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based

More information

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.

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. Bits and Bytes 1 A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices. A byte is a sequence of 8 bits. A byte is also the fundamental unit of storage

More information

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

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Pradip Vallathol and Junaid Khalid Midterm Examination 1 In Class (50 minutes) Friday, September

More information

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

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We

More information

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

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Junaid Khalid and Pradip Vallathol Midterm Examination 1 In Class (50 minutes) Friday, September

More information

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

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL EE 9 Unit Binary Representation Systems ANALOG VS. DIGITAL Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world is based on discrete

More information

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

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme 2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme repeated (integer) division by two. Example: What is

More information

ASSIGNMENT 5 TIPS AND TRICKS

ASSIGNMENT 5 TIPS AND TRICKS ASSIGNMENT 5 TIPS AND TRICKS linear-feedback shift registers Java implementation a simple encryption scheme http://princeton.edu/~cos26 Last updated on /26/7 : PM Goals OOP: implement a data type; write

More information

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

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes Multiple-byte data CMSC 313 Lecture 03 big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes UMBC, CMSC313, Richard Chang 4-5 Chapter

More information

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012 CMSC 33 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 2, FALL 22 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point formats

More information

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10? Where Have We Been? Class Introduction Great Realities of Computing Int s are not Integers, Float s are not Reals You must know assembly Memory Matters Performance! Asymptotic Complexity It s more than

More information

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

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation 3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based

More information

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra Expressing

More information

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

CPS 104 Computer Organization and Programming Lecture-2 : Data representations, CPS 104 Computer Organization and Programming Lecture-2 : Data representations, Sep. 1, 1999 Dietolf Ramm http://www.cs.duke.edu/~dr/cps104.html CPS104 Lec2.1 GK&DR Fall 1999 Data Representation Computers

More information

Bits, Bytes, and Integers

Bits, Bytes, and Integers Bits, Bytes, and Integers B&O Readings: 2.1-2.3 CSE 361: Introduc=on to Systems So@ware Instructor: I- Ting Angelina Le e Note: these slides were originally created by Markus Püschel at Carnegie Mellon

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by

More information

Number Systems Base r

Number Systems Base r King Fahd University of Petroleum & Minerals Computer Engineering Dept COE 2 Fundamentals of Computer Engineering Term 22 Dr. Ashraf S. Hasan Mahmoud Rm 22-44 Ext. 724 Email: ashraf@ccse.kfupm.edu.sa 3/7/23

More information

Oberon Data Types. Matteo Corti. December 5, 2001

Oberon Data Types. Matteo Corti. December 5, 2001 Oberon Data Types Matteo Corti corti@inf.ethz.ch December 5, 2001 1 Introduction This document is aimed at students without any previous programming experience. We briefly describe some data types of the

More information

Bits and Bytes January 13, 2005

Bits and Bytes January 13, 2005 15-213 The Class That Gives CMU Its Zip! Topics Bits and Bytes January 13, 25 Why bits? Representing information as bits Binary / Hexadecimal Byte representations» Numbers» Characters and strings» Instructions

More information

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices

More information

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

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example The Basics Binary Numbers Part Bit of This and a Bit of That What is a Number? Base Number We use the Hindu-Arabic Number System positional grouping system each position represents a power of Binary numbers

More information

The Design of C: A Rational Reconstruction"

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

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

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program

More information

Bits, Bytes, and Integers Part 2

Bits, Bytes, and Integers Part 2 Bits, Bytes, and Integers Part 2 15-213: Introduction to Computer Systems 3 rd Lecture, Jan. 23, 2018 Instructors: Franz Franchetti, Seth Copen Goldstein, Brian Railing 1 First Assignment: Data Lab Due:

More information

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

Under the Hood: Data Representation. Computer Science 104 Lecture 2 Under the Hood: Data Representation Computer Science 104 Lecture 2 Admin Piazza, Sakai Up Everyone should have access Homework 1 Posted Due Feb 6 PDF or Plain Text Only: No Word or RTF Recommended: Learn

More information

Lecture 5-6: Bits, Bytes, and Integers

Lecture 5-6: Bits, Bytes, and Integers CSCI-UA.0201-003 Computer Systems Organization Lecture 5-6: Bits, Bytes, and Integers Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Slides adapted from: Jinyang Li Bryant and O Hallaron

More information

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point

More information

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) Systems Software & Architecture Lab. Seoul National University Integers Spring 2019 4190.308: Computer Architecture Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) 2 A

More information

Bits, Bytes, and Integers

Bits, Bytes, and Integers Bits, Bytes, and Integers with contributions from Dr. Bin Ren, College of William & Mary 1 Bits, Bytes, and Integers Representing information as bits Bit-level manipulations Integers Representation: unsigned

More information

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Bits, Bytes and Integers

Bits, Bytes and Integers Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran

More information

The Binary Number System

The Binary Number System The Binary Number System Robert B. Heckendorn University of Idaho August 24, 2017 Numbers are said to be represented by a place-value system, where the value of a symbol depends on where it is... its place.

More information

Positional Number System

Positional Number System Positional Number System A number is represented by a string of digits where each digit position has an associated weight. The weight is based on the radix of the number system. Some common radices: Decimal.

More information

Simple Data Types in C. Alan L. Cox

Simple Data Types in C. Alan L. Cox Simple Data Types in C Alan L. Cox alc@rice.edu Objectives Be able to explain to others what a data type is Be able to use basic data types in C programs Be able to see the inaccuracies and limitations

More information

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

CS341 *** TURN OFF ALL CELLPHONES *** Practice NAME CS341 *** TURN OFF ALL CELLPHONES *** Practice Final Exam B. Wilson NAME OPEN BOOK / OPEN NOTES: I GIVE PARTIAL CREDIT! SHOW ALL WORK! 1. Processor Architecture (20 points) a. In a Harvard architecture

More information

Hardware: Logical View

Hardware: Logical View Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes

More information

The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra

More information

Fundamental Data Types

Fundamental Data Types Fundamental Data Types Lecture 4 Sections 2.7-2.10 Robb T. Koether Hampden-Sydney College Mon, Sep 3, 2018 Robb T. Koether (Hampden-Sydney College) Fundamental Data Types Mon, Sep 3, 2018 1 / 25 1 Integers

More information

Characters Lesson Outline

Characters Lesson Outline Outline 1. Outline 2. Numeric Encoding of Non-numeric Data #1 3. Numeric Encoding of Non-numeric Data #2 4. Representing Characters 5. How Characters Are Represented #1 6. How Characters Are Represented

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

The Design of C: A Rational Reconstruction" Jennifer Rexford!

The Design of C: A Rational Reconstruction Jennifer Rexford! The Design of C: A Rational Reconstruction" Jennifer Rexford! 1 Goals of this Lecture"" Number systems! Binary numbers! Finite precision! Binary arithmetic! Logical operators! Design rationale for C! Decisions

More information

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices

More information

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.

This is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor. Dealing With ASCII ASCII, of course, is the numeric representation of letters used in most computers. In ASCII, there is a number for each character in a message. Max does not use ACSII very much. In the

More information

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

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc. 9 February 2011 CSE-1520R Test #1 [B4] p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The exam is closed

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

More information

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

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012 ANNOUNCEMENTS TA Office Hours (ITE 334): Genaro Hernandez, Jr. Mon 10am 12noon Roshan Ghumare Wed 10am 12noon Prof.

More information

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

Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013 Number Systems II MA1S1 Tristan McLoughlin November 30, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/18 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii

More information

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.

More information

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

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program. Experiment 3 Introduction: In this experiment the students are exposed to the structure of an assembly language program and the definition of data variables and constants. Objectives: Assembly language

More information

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

CSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc. 9 February 2011 CSE-1520R Test #1 [7F] w/ answers p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The

More information

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

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums plc numbers - 3. 3. NUMBERS AND DATA Topics: Number bases; binary, octal,, hexa Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;

More information

Chapter 8. Characters and Strings

Chapter 8. Characters and Strings Chapter 8 Characters and s OJECTIVES After you have read and studied this chapter, you should be able to Declare and manipulate data of the char data type. Write string processing programs using and uffer

More information

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

5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital Chapter 8: Bits and the "Why" of Bytes: Representing Information Digitally Digitizing Discrete Information Fluency with Information Technology Third Edition by Lawrence Snyder Copyright 2008 Pearson Education,

More information

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

EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART) EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: To understand and apply USART command for sending and receiving data Introduction Universal Serial Asynchronous

More information

The following are the data types used in the C programming language:

The following are the data types used in the C programming language: Data Types in C The following are the data types used in the C programming language: Type Definition Size in memory void This particular type is used only in function declaration. boolean It stores false

More information

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

EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART) EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: Introduction To understand and apply USART command for sending and receiving data Universal Serial Asynchronous

More information

Computer Systems CEN591(502) Fall 2011

Computer Systems CEN591(502) Fall 2011 Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 4 th lecture Data representation in computer systems (Slides adapted from CSAPP book) Announcements Programming assignment

More information

CSE 30 Fall 2013 Final Exam

CSE 30 Fall 2013 Final Exam Login: cs30x Student ID Name Signature By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1

1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1 Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 1. Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 2. Numeric Representation of

More information

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program

More information

Bits and Bytes: Data Presentation Mohamed Zahran (aka Z)

Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) CSCI-UA.0201 Computer Systems Organization Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted and modified from: Clark Barrett Jinyang

More information

COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing. Number Systems COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

More information

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring: ECE 120 Midterm 1 HKN Review Session Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location: Your Room on Compass What to bring: icard, pens/pencils, Cheat sheet (Handwritten) Overview of Review Binary IEEE

More information

CSE 30 Winter 2014 Final Exam

CSE 30 Winter 2014 Final Exam Signature Login: cs30x Name Student ID By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.

More information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition Carnegie Mellon 1 Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Aug. 31, 2017 Today s Instructor: Randy Bryant 2 Announcements Recitations are on

More information

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean

More information

The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction The Design of C: A Rational Reconstruction 2 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

More information

Lecture 2: Number Representa2on

Lecture 2: Number Representa2on CSE 30: Computer Organization and Systems Programming Lecture 2: Number Representa2on Diba Mirza University of California, San Diego 1 Levels of Representation High Level Language Program (e.g., C) Compiler

More information

Binary Representations and Arithmetic

Binary Representations and Arithmetic Binary Representations and Arithmetic 9--26 Common number systems. Base : decimal Base 2: binary Base 6: hexadecimal (memory addresses) Base 8: octal (obsolete computer systems) Base 64 (email attachments,

More information

Variables and data types

Variables and data types Programming with Python Module 1 Variables and data types Theoretical part Contents 1 Module overview 4 2 Writing computer programs 4 2.1 Computer programs consist of data and instructions......... 4 2.2

More information

CSE 30 Fall 2007 Final Exam

CSE 30 Fall 2007 Final Exam Login: cs30x Student ID Name Signature CSE 30 Fall 2007 Final Exam 1. Number Systems (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching (19 points) 4. Bit Operations

More information

Representing and Manipulating Integers. Jo, Heeseung

Representing and Manipulating Integers. Jo, Heeseung Representing and Manipulating Integers Jo, Heeseung Unsigned Integers Encoding unsigned integers B [ bw 1, bw 2,..., b0 ] x = 0000 0111 1101 0011 2 D( B) w 1 b i i 0 2 i D(x) = 2 10 + 2 9 + 2 8 + 2 7 +

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information