Exercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014
|
|
- Clemence McCoy
- 5 years ago
- Views:
Transcription
1 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 Riener Institute for Pervasive Computing Johannes Kepler University Linz riener@pervasive.jku.at
2 Terminology: Variables Each variable is, when defined, related to a specific data type Data type defines the range of values, e.g., byte = (8bit) At runtime, each and every variable has also assigned a concrete value Default value Assigned by the programmer Determined within assignment operation Values (eger, float, characters, etc.) are ernally represented (i.e., working memory) as binary numbers ( calculating with binary numbers?) Data type conversions Possible, but not always without loss (of precision) Software Development I // Exercises // 03 Data Representation // 2
3 Variables: Data Types and Range of Values Integer types byte 8bit -128 to +127 short 16bit to bit to (= to 2 31, 32nd bit used for sign) long 64bit to Floating-po types float 32bit single precision double 64bit double precision Character type char 16bit single character, Unicode character set modes of assignments 1) alphanumeric character in single quote ('a', 'B', etc.) 2) 4-digit hexadecimal Unicode index (\u0000 to \uffff) 3) Integer value (16bit unsigned; 0 to 65535) (?) Software Development I // Exercises // 03 Data Representation // 3
4 Internal Format: Integer Values Values (of any data type) are ernally represented as binary numbers (sequence of digits 0/1) Example: short number1, number2, result; //short 16 bit number1 = 7; number2 = 15; result = number1 + number2; result = (short) number1 + number2; // Java speciality! // (more later) //calculation number1 = number2 = result = Software Development I // Exercises // 03 Data Representation // 4
5 Internal Format: From Binary to Integer Numbers Given: binary number b n+1 b n b n-1... b 2 b 1 //b n+1 = sign Leading sign: 1st (leading) bit as indicator for positive/negative number b n+1 = 0 positive number b n+1 = 1 negative number Wanted: its (positive) eger value x x = n i= 1 2 Example: x x x x x 2 4 = st bit is reserved for the leading sign maximum positive number (data type short): 16bit 1bit (sign) = = = b i i 1 [short: n=15, : n=31, long: n=63] Software Development I // Exercises // 03 Data Representation // 5
6 Internal Format: (Negative) Integer Values Given: binary number b n+1 b n b n-1... b 2 b 1 //b n+1 = sign Wanted: its (negative) eger value x not that easy: different variants possible (dependent, e.g., on computer or operating system architecture) Variant 1: Simple signed Binary number b n+1 b n b n-1... b 2 b 1 Remember: b n+1 =0 for positive numbers, b n+1 =1 for negative numbers Example (datatype short): Integer number 24 = , data type short (2 Byte) Integer number -24 = , data type short (2 Byte) All the other digits are not affected by the most significant digit (sign) Software Development I // Exercises // 03 Data Representation // 6
7 Internal Format: (Negative) Integer Values Variant 2: One s complement b n+1 =1 (negative number): bitwise inversion of every digit Example (datatype short): Integer number 24 = , data type short (2 Byte) Integer number -24 = , data type short (2 Byte) Software Development I // Exercises // 03 Data Representation // Every single digit is affected by the sign inversion is effective! Variant 3: Two s complement (implemented in Java) b n+1 =1 (negative number): one s complement + 1 Example (datatype short): Integer number 24 = , data type short (2 Byte) Integer number -24 = , data type short (2 Byte) [one s complement) Integer number -24 = , data type short (2 Byte) [two s complement) Todays computer system usually implement two s complement reason: simplified ernal representation (no additional control logic)
8 I Internal Format: Why is the negative number range greater by one? Expert knowledge Internal representation (example 16bit): Largest positive number ( = 32767) Largest negative number; Expectation = -(largest positive number + 1)? (1) // if data type not fixed to 16bit, // i.e., no overflow One s complement: (0) Two s complement (=One s complement + 1): Software Development I // Exercises // 03 Data Representation // 8
9 Internal Format: Floating-po Numbers s e1 e2... e8 f1 f2 f3... f23 Sign s Exponent e Mantissa M 0 = +; 1 = - exp floating-po num. <1; power of 2 (neg.) Normalized representation: (-1) s 2 exp M (for 0 < e < 255) M = f 1 x f 2 x f 3 x f 23 x 2-23 Not every real number can be represented using this floating-po format. Why? Each and every finite erval [a, b[ has room for endless (infinite) real numbers Only a subset of them can be represented using only a finite number of n Bytes (e.g. in Java n=4 for float, n=8 for double) Software Development I // Exercises // 03 Data Representation // 9
10 Internal Format: Floating-po Numbers Example: Floating-po number Leading sign: s = -1 Exponent exp = 134 ( =134) Mantissa M = 0 x x x = 0.25 Result (floating-po number): = = exact, i.e., no loss of precision! Software Development I // Exercises // 03 Data Representation // 10
11 Internal Format: Floating-po Numbers Special cases +/- Infinity and Not-a-Number (NaN) requires particular requirements/predefinitions +/- Infinity: Mantissa M is set to 0, exponent exp is set to Infinity binary representation: floating-po number: = = Infinity - Infinity binary representation: floating-po number: = = -Infinity Not-a-Number: Mantissa M is >0 (any digit!=0), exponent exp is set to 255 NaN binary representation:? ??????????????????????? 2 floating-po number:? ? =? ? = NaN Software Development I // Exercises // 03 Data Representation // 11
12 Internal Format: Floating-po Numbers Floating-po number 0.0 requires special treatment (not representable in standard floating-po format!) s e1 e2... e8 f1 f2 f3... f23 Sign s Exponent e Mantissa M 0 = +; 1 = - exp floating-po num. <1; power of 2 (neg.) Sub-normal representation: (-1) s M (for e=0) M = f 1 x f 2 x f 3 x f 23 x 2-23 Mantissa M = 0, exponent exp = (positive) binary representation: floating-po number: = (negative) binary representation: floating-po number: = -0.0 Software Development I // Exercises // 03 Data Representation // 12
13 I SWE1 UE03 RoundingError.zip Internal Format: Floating-po Numbers Origin of rounding errors Example: float f1 = 1.1f; float f2 = 0.1f; float f3 = f1-2*f2; // exact value: 1.1f-2*0.1f = 0.9f if (f1==1.1f) System.out.prln(f1); // output: "1.1" if (f2==0.1f) System.out.prln(f2); // output: "0.1" if (f3==0.9f) System.out.prln(f3); // never reached; f3 is ! if (f3==(1.1f-2*0.1f)) System.out.prln(f3); // reached; output: " " Software Development I // Exercises // 03 Data Representation // 13
14 Implicit, explicit type conversions
15 I Data Types: Implicit Type Conversion +-*/% char byte short long float double char long float double byte long float double short long float double long float double long long long long long long float double float float float float float float float double double double double double double double double double Software Development I // Exercises // 03 Data Representation // 15
16 Data Types: Numeric Type Conversions Implicit & Explicit Rules for implicit (i.e., no type cast) and explicit type conversions Any eger type can be assigned without explicit conversion to any other greater (i.e., more bits ) eger type (e.g. byte, short to ) Character data type char is without explicit type conversion compatible to be assigned to all eger types (, and long) (Explicitly) converting an eger data type o another eger type of smaller size (i.e., fewer bits ): higher bits are truncated, the leading sign (most significant bit) is cut as well (sign is not adjusted!) Conversion from floating-po type double to float: Result is rounded (that float value with fewest difference to the original double value) Conversion from floating-po to eger data type is done by simply truncating all the decimal places (rounding against zero!); is the eger part of the floating-po number too large to fit o the corresponding eger data type then the result is the maximum (or minimum) representable number of that data type Software Development I // Exercises // 03 Data Representation // 16
17 Data Types: Conversion from Floating-po to Integer Number In any case such a conversion requires an explicit type cast; Java uses rounding against zero loss of precision! Example Truncating public static void main (String[] arg) { res1, res2; float number1 = 12.34f; double number2 = ; } res1 = ()number1; res2 = ()number2; System.out.prln(res1); System.out.prln(res2); Results res1 = 12 res2 = -67 Example Overflow public static void main (String[] arg) { float numfl = f; numint; > MAX(); result: numint = MAX() = Software Development I // Exercises // 03 Data Representation // 17 } numint = ()numfl; System.out.prln(numInt); Result numint =
18 Data Types: Conversion from Integer to Integer Number Converting from large eger type o another eger type of smaller size (i.e., fewer bits ): higher bits are truncated, no sign adjustment public static void main (String[] arg) { numint1 = ; // numint2 = ; // short numshort1 = (short) numint1; // short numshort2 = (short) numint2; // } System.out.prln(numShort1); System.out.prln(numShort2); 32bit 16bit most significant bit = sign! Results numshort1 = numshort2 = 7616 ( =7616) Software Development I // Exercises // 03 Data Representation // 18
19 I Data Types: Character representation (type char) ASCII (American Standard Code for Information Interchange) code table Char Dec Oct Hex Char Dec Oct Hex Char Dec Oct Hex Char Dec Oct Hex (nul) x00 (sp) x40 ` x60 (soh) x01! x21 A x41 a x61 (stx) x02 " x22 B x42 b x62 (etx) x03 # x23 C x43 c x63 (eot) x04 $ x24 D x44 d x64 (enq) x05 % x25 E x45 e x65 (ack) x06 & x26 F x46 f x66 (bel) x07 ' x27 G x47 g x67 (bs) x08 ( x28 H x48 h x68 (ht) x09 ) x29 I x49 i x69 (nl) x0a * x2a J x4a j x6a (vt) x0b x2b K x4b k x6b (np) x0c, x2c L x4c l x6c (cr) x0d x2d M x4d m x6d (so) x0e x2e N x4e n x6e (si) x0f / x2f O x4f o x6f (dle) x x30 P x50 p x70 (dc1) x x31 Q x51 q x71 (dc2) x x32 R x52 r x72 (dc3) x x33 S x53 s x73 (dc4) x x34 T x54 t x74 (nak) x x35 U x55 u x75 (syn) x x36 V x56 v x76 (etb) x x37 W x57 w x77 (can) x x38 X x58 x x78 (em) x x39 Y x59 y x79 (sub) x1a : x3a Z x5a z x7a (esc) x1b ; x3b [ x5b { x7b (fs) x1c < x3c \ x5c x7c (gs) x1d = x3d ] x5d } x7d (rs) x1e > x3e ^ x5e ~ x7e (us) x1f? x3f _ x5f (del) x7f Software Development I // Exercises // 03 Data Representation // 19 Specific mapping between character and number (1-127) After the 128 th character, the mapping allows for country (code table) specific character sets, etc.
20 Data Types: Character representation (type char) Examples: Calculation with characters public static void main (String[] arg) { char charres = 'b'-'a'; = = 1 System.out.prln(()charRes); System.out.prln('b'-'a'); // simplified } Reverse calculation: from number to character public static void main (String[] arg) { char chara = 'A'; char charb; } charb = (char) (chara+1); = (char)(65+1) = (char)66 = 'B' System.out.prln(()charB); System.out.prln('A'+1); // simplified Application: Lowercase to uppercase conversion public static void main (String[] arg) { char charupper, charlower = 'q'; charupper = (char) (charlower-'a'+'a'); } Software Development I // Exercises // 03 Data Representation // 20 = (char)( ) = (char) 81 = 'Q'
21 Literals in Java In computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as egers, floating-po numbers, strings, and booleans
22 I Java Literals: General Introduction What you type is what you get By literal we mean any number, text, or other information that represents a (concrete) value ( constant ) Literals in a Java program represent fixed and atomic values Literals must not be mixed up with the declaration of constants Example //eger literal, value 10 month = 10; In Java the following types of literals are known Integer/long numbers: 0; 123; 0xDadaCafe / 12L; 022L; Float/double numbers: 3.2f; -3e-22f / 3.2; -3e-22D Logic literals: true; false Character literals: 'A'; 'z'; '1' String literals: ""; "\""; "Hello World Reference literals: null; this; super Software Development I // Exercises // 03 Data Representation // 22
23 Java Literals: Integer type Integer literals are a sequence of digits To represent the type as long eger the value is followed by a suffix L or l Integer variables may be represented in Decimal format (base 10): default, no prefix/suffix needed - Example age = 19; Decimal format, long - Example long longliteral = L; Octal format (base 8): prefix 0 (zero) followed by digits 0 to 7 - Example octage = 023; Hexadecimal (base 16) : prefix 0x - Examples hexage = 0x13; short largeshort = 0xff32; // Software Development I // Exercises // 03 Data Representation // 23
24 Java Literals: Hands on Experience (Integer) What about eger literals of type short/byte? eger literals are in Java always of type or long no short/byte literals, Examples short s = 100; // max(s)=32767 // ok; literal; implicit type cast to 'short' (compiler) // assigned only if '' literal fits o 'short' type short s = ; // max(s)=32767 // Type mismatch: cannot convert from to short short s = ; // max(s)=32767 // The literal of type is out of range // Type mismatch: cannot convert from to short short s = L; // max(s)=32767 // Type mismatch: cannot convert from long to short Software Development I // Exercises // 03 Data Representation // 24
25 Java Literals: Character type Character literals are specified as a single prable character in a pair of single quote characters (ASCII character set: letters, numerals, punctuations, etc.) Standard characters - Examples char h = 'h', e = 'E', one = '1', special = '#'; Characters represented by their eger value (dec, hex, oct, dec) - Examples char h = 104, e = 0x45, one = 061, special = 35; Special characters (not readily prable through a keyboard): Escape sequences - Examples char newline = '\n', singlequote = '\'', backslash = '\\'; - Newline symbol - can be used to detect if the user has pressed the return key - but: '\n' may have, depending on the platform, different meaning, e.g. carriage return (CR), carriage return + line feed (CR+LF), etc. - in Java both symbols ('\n', '\r' ) have different, fixed values! Software Development I // Exercises // 03 Data Representation // 25
26 Java Literals: Character type (con t) Character literals are specified as a single prable character in a pair of single quote characters (ASCII character set: letters, numerals, punctuations, etc.) Escape sequences in combination with numbers '\d' octal '\xd' hexadecimal '\ud' Unicode character d represents in each case a number Examples char unicodechar = '\u0041' //capital letter A = '\u0030' //digit 0 = '\u0022' //double quote " = '\u003b' //punctuation ; = '\u0009' //horizontal tab Software Development I // Exercises // 03 Data Representation // 26
27 Java Literals: Floating po type Floating po literals are like real numbers in mathematics Java has two kinds of floating po numbers: float and double; default type when you enter a floating po literal is double Floating po literals can be denoted as a decimal po, a fraction part, an exponent (represented by e or E), or as an eger; to represent the precision a suffix f or F (float) or d/d (double) may be added Examples Single precision float one = 1.0f, pi = f, num = 4/5f, small = 2.9e-12f; Double precision double large = 6.5E32, one = 1D, belowzero= ; Software Development I // Exercises // 03 Data Representation // 27
28 Java Literals: Hands on Experience (Float) Mixed operations with float/double literals Example 1 float weight = 1.3; float weight = 1.3f; double weight = 1.3f; float f1 = (float)1.2; Error: double float ( type mismatch: cannot convert... ) Example 2 byte count = 5; float totalweight = count * weight; totalweight = count float * weight float = 5.0 * 1.3 = 6.5 Example 3 double x = 2.0 * 0.5; y; y = x; y = ()x; ok: explicit cast = () 1.0 = 1 Error: double ( type mismatch: cannot convert... ) Software Development I // Exercises // 03 Data Representation // 28
29 I SWE1 UE03 RoundingError.zip Java Literals: Hands on Experience (Float) Wrong result for the division of two numbers ( literals ) Why? Example:! float onethirdwrong = 3/9; // 3() /() 9() = 0() -> 0.0(float) WRONG! float onethirdcorrect = 3f/9; // 3(float) /(float) 9(float) = (float)! number1 = 10; number2 = 3; double result = number1 / number2; // Same as before: division in type (type conversion table!) // Result enlarged to double (3 -> 3.0f), assigned to result WRONG! // Also wrong; 10/3 () = 3 -> 3.0D, assigned to result result = (double)(number1 / number2); // Correct solution ( ): // Use explicit type cast (either of number1 or number2) result = (double)number1 / number2; result = number1 / (double)number2; Software Development I // Exercises // 03 Data Representation // 30
30 I Data Types: Calculations with Different, Mixed Types Just few simple rules Data type with greater range of values dominates Explicit type casts to smaller data types Take care of decimal places and range of values (overflow) In-class activity (try on your own!) //use in each case the initial assignment a = 10; short b = 20; byte c = 30; float d = 1.2f; double e = 2.2; problem1: a + b + c + d + e =? problem2: a + b + c + () (d + e) =? problem3: () (e * e) (5 b c) * d =? Software Development I // Exercises // 03 Data Representation // 31
31 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 Riener Institute for Pervasive Computing Johannes Kepler University Linz riener@pervasive.jku.at
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 information1.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 informationNumber 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 informationChapter 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 informationChapter 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 informationNumber 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 informationData 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 informationChapter 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 informationUnder 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 informationFundamentals 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 informationChapter 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 informationEE 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 informationData 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 information2a. 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 informationData 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 information3.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 informationUnit 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 informationDATA 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 informationChapter 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 informationEE 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 informationCMSC 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 informationOberon 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 informationCS/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 informationCS/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 informationNumber 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 informationNumber 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 informationEE 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 informationFundamental 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 informationNumbers 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 informationChapter 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 informationUnit 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 informationDo 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 informationBits 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 informationChapter 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 informationFundamentals 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 informationCMSC 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 informationBinary 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 informationNumber 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 informationSimple 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 informationEXPERIMENT 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 informationThe 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 informationEXPERIMENT 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 information5/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 informationCSE-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 informationExperiment 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 informationCMSC 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 informationCSE-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 informationASSIGNMENT 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 informationCS341 *** 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 informationplc 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 informationChapter 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 informationSource coding and compression
Computer Mathematics Week 5 Source coding and compression College of Information Science and Engineering Ritsumeikan University last week binary representations of signed numbers sign-magnitude, biased
More informationPositional 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 informationCOMP2121: 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 informationDo 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 informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
More informationCMSC 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 informationStandard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)
Standard 11 Lesson 9 Introduction to C++( Up to Operators) 2MARKS 1. Why C++ is called hybrid language? C++ supports both procedural and Object Oriented Programming paradigms. Thus, C++ is called as a
More informationRS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200
RS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200 Biamp Systems, 14130 N.W. Science Park, Portland, Oregon 97229 U.S.A. (503) 641-7287 an affiliate of Rauland-Borg Corp. Introduction
More informationReview. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale
Review Single Pixel Filters Thresholding Posterize Histogram Equalization Negative Sepia Grayscale Spatial Filters Smooth Blur Low Pass Filter Sharpen High Pass Filter Erosion Dilation Image Processing
More informationPureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -
PureScan - ML1 Wireless Linear Imager Wireless Laser scanner Configuration Guide - 1 - Table of Contents Chapter 1 System Information 1.1 About this manual 3 1.2 How to set up the parameter 3 Chapter 2
More informationvoid mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }
Review Commenting your code Random numbers and printing messages mousex, mousey void setup() & void draw() framerate(), loop(), noloop() Arcs, curves, bézier curves, beginshape/endshape Example Sketches
More information1. 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 informationCSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems
CSC 8400: Computer Systems Represen3ng and Manipula3ng Informa3on Background: Number Systems 1 Analog vs. Digital System q Analog Signals - Value varies con1nuously q Digital Signals - Value limited to
More informationCPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation
CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation George Tsiknis University of British Columbia Department of Computer Science Winter Term 2, 2015-2016 Last updated: 04/04/2016
More informationFD-011WU. 2D Barcode Reader User Guide V1.6CC
FD-011WU 2D Barcode Reader User Guide V1.6CC Table of Contents 1 Getting Started... 1 1.1 Factory Defaults... 1 2 Communication Interfaces...2 2.1 TTL-232 Interface... 2 2.2 Baud Rate... 3 2.3 Data Bit
More informationVariables 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 informationCSE 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 informationCSE 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 informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationIntroduction 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 informationDo 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 informationCharacters 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 informationExercises Software Development I. 05 Conversions and Promotions; Lifetime, Scope, Shadowing. November 5th, 2014
Exercises Software Development I 05 Conversions and Promotions; Lifetime, Scope, Shadowing November 5th, 2014 Software Development I Winter term 2014/2015 Priv.-Doz. Dipl.-Ing. Dr. Andreas Riener Institute
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationLecture (09) x86 programming 8
Lecture (09) x86 programming 8 By: Dr. Ahmed ElShafee 1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
More informationCSE 30 Spring 2007 Final Exam
Login: cs30x Student ID Name Signature CSE 30 Spring 2007 Final Exam 1. Number Systems (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching (19 points) 4. Bit
More informationInf2C - Computer Systems Lecture 2 Data Representation
Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack
More informationmarson MT8200S 2D Handheld Scanner User Manual V / 6 / 25 - I -
marson MT8200S 2D Handheld Scanner User Manual V1.1 2018 / 6 / 25 - I - Table of Contents 1 Gettting Started...1 1.1 Introduction...1 1.2 Configuring MT8200S...1 1.2.1 Barcode Configurability...1 1.2.2
More informationWork relative to other classes
Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language
More informationRS-232 Control of the Advantage DRI
RS-232 Control of the Advantage DRI Biamp Systems, 14130 N.W. Science Park, Portland, Oregon 97229 U.S.A. (503) 641-7287 an affiliate of Rauland-Borg Corp. Introduction This document contains technical
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationTime: 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 informationCSE 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 informationGetting started with Java
Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving
More informationComputer System and programming in C
1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign
More informationInteger Representation Floating point Representation Other data types
Chapter 2 Bits, Data Types & Operations Integer Representation Floating point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human
More informationMACHINE LEVEL REPRESENTATION OF DATA
MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems
More informationThis 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 informationASCII Code - The extended ASCII table
ASCII Code - The extended ASCII table ASCII, stands for American Standard Code for Information Interchange. It's a 7-bit character code where every single bit represents a unique character. On this webpage
More informationTable of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup
Table of Contents Chapter 1 System Information 1.1 Setup Scanner with PC 1.2 Setup Scanner with Mobile Device 1.3 Configure ios On-Screen Keyboard 1.4 Memory Mode 3 4 4 5 1.5 Sleep Settings 6 1.6 How to
More informationUNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES
UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES Structure 2.0 Introduction 2.1 Unit Objectives 2.2 Number Systems 2.3 Bits and Bytes 2.4 Binary Number System 2.5 Decimal Number System 2.6 Octal Number System
More informationMK D Imager Barcode Scanner Configuration Guide
MK-5500 2D Imager Barcode Scanner Configuration Guide V1.4 Table of Contents 1 Getting Started... 3 1.1 About This Guide... 3 1.2 Barcode Scanning... 3 1.3 Factory Defaults... 3 2 Communication Interfaces...
More informationWeek 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals. Alvin Valera. School of Engineering and Computer Science Victoria University of Wellington
Week 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals Alvin Valera School of Engineering and Computer Science Victoria University of Wellington Admin stuff People Course Coordinator Lecturer Alvin Valera
More informationThese are reserved words of the C language. For example int, float, if, else, for, while etc.
Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.
More informationCSE 30 Spring 2006 Final Exam
cs30x_ Student ID Name _ Signature CSE 30 Spring 2006 Final Exam 1. Number Systems _ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection _ (12 points) 3. Branching _ (18 points) 4. Bit
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationCOMP6700/2140 Data and Types
COMP6700/2140 Data and Types Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU February 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Data and Types February
More informationCSE 30 Winter 2009 Final Exam
Login: cs30x Student ID Name Signature CSE 30 Winter 2009 Final Exam 1. Number Systems / C Compiling Sequence (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More information