Chapter 2 CREATING DATA FIELDS. SYS-ED/ Computer Education Techniques, Inc.

Size: px
Start display at page:

Download "Chapter 2 CREATING DATA FIELDS. SYS-ED/ Computer Education Techniques, Inc."

Transcription

1 Chapter 2 CREATING DATA FIELDS SYS-ED/ Computer Education Techniques, Inc.

2 Objectives You will learn: Declaring PL/1 variables with scale, base, and mode. The internal representation of numeric, character, and varying character strings. Differences between the number types and which types to use for a particular circumstance. Declaring and using bit strings. Initializing a variable in the Declare statement. Formatting data items for printing or writing to a dataset. Coding the PICTURE specification in a DECLARE. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page i

3 1 Data Items A data item is either the value of a variable or a constant. Data items can be: Scalars Data aggregates Single items. Collection of data items that can be referred to either collectively or individually. Data aggregates are groups of data items. There are three kinds of data aggregates: arrays structures unions 1.1 Variable A variable has a value or values that might change during execution of a program. It is introduced by a declaration, which declares the name and certain attributes of the variable 1.2 Constant A constant has a value that cannot change. Constants for computational data are referred to by stating the value of the constant or naming the constant in a DECLARE statement String constants, hexadecimal constants, and the picture-specification are enclosed in either single or double quotation marks. If the included quotation marks are the same type as those used to enclose the string, two quotation marks must be entered for each occurrence to be included. For purposes of improving readability, arithmetic, bit, and hexadecimal constants can use the break character ( _ ). CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 1

4 2 Data Types and Attributes Data used in a PL/1 program can be classified as either computational data or program-control data. Computational data Program-control data Represents values that are used in computations to produce a desired result. Arithmetic and string data constitute computational data. Represents values that are used to control execution of your program. It consists of the following data types: area, entry, label, file, format, pointer, and offset. 2.1 Numeric Data The base of a coded arithmetic data item is either decimal or binary. DECIMAL is the default. The scale of a coded arithmetic data item is either fixed-point or floating-point. The precision of a coded arithmetic data item includes the number of digits and the scaling factor. The mode of an arithmetic data item, coded arithmetic or numeric character, is either real or complex. The SIGNED and UNSIGNED attributes can be used only with FIXED BINARY variables and ORDINAL variables. SIGNED indicates that the variable can assume negative values. UNSIGNED indicates that the variable can assume only nonnegative values. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 2

5 2.2 Binary Fixed-point Data The data attributes for declaring binary fixed-point variables are BINARY and FIXED. declare Factor binary fixed (20,2); Factor is declared as a variable that can represent binary fixed-point data of 20 data bits; two of which are to the right of the binary point. A binary fixed-point constant consists of one or more bits with an optional binary point, followed immediately by the letter B. Binary fixed-point constants have a precision (p,q), where p is the total number of data bits in the constant, and q is the number of bits to the right of the binary point. Examples: Constant Precision 1011_0B (5,0) 1111_1B (5,0) 101B (3,0) B (7,3) 2.3 Decimal Fixed-point Data The data attributes for declaring decimal fixed-point variables are DECIMAL and FIXED. declare A fixed decimal (5,4); This code specifies that A represents decimal fixed-point data of 5 digits; 4 of which are to the right of the decimal point. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 3

6 declare B fixed (7,0) decimal; declare B fixed decimal(7); These two code fragments specify that B represents integers of 7 digits. A decimal fixed-point constant consists of one or more decimal digits with an optional decimal point. Decimal fixed-point constants have a precision (p,q), where p is the total number of digits in the constant and q is the number of digits specified to the right of the decimal point. Constant Precision (5,4) (4,1) 732 (3,0) 1_200_300 (7,0) 003 (3,0) 5280 (4,0).0012 (4,4) /* Calculation Program */ CALC: PROC OPTIONS(MAIN); DCL I1 FIXED BIN(31) INIT(5); DCL I2 FIXED BIN(31) INIT(6); I1 = I2 * 2; PUT LIST(' I1 IS ', I1); END CALC; CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 4

7 2.4 Binary Floating-point Data The data attributes for declaring binary floating-point variables are: BINARY FLOAT declare S binary float (16); S represents binary floating-point data with a precision of 16 binary digits. A binary floating-point constant is a mantissa followed by an exponent and the letter B. The mantissa is a binary fixed-point constant. Examples: Constant Precision E5B (6) E2B (6) 11101E-28B (5) 11.01E+42B (4) 2.5 String Data and Attributes Attribute BIT attribute CHARACTER attribute PICTURE attribute WIDECHAR GRAPHIC attribute Description Specifies a bit variable. Specifies a character variable. Character strings can also be declared. Specifies a widechar variable which will hold UTF-16 data. Specifies a graphic variable. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 5

8 declare User character (15); The statement declares User as a variable that can represent character data with a length of 15: declare Symptoms bit (64); This code fragment declares a bit variable. Data with the CHARACTER attribute can contain any of the 256 characters supported by the character set. The VARYING and VARYINGZ attributes specify that a variable can have a length varying from 0 to the declared maximum length. NONVARYING specifies that a variable always has a length equal to the declared length. The storage allocated for VARYING strings is 2 bytes longer than the declared length. o The leftmost 2 bytes hold the string s current length. The storage allocated for a VARYINGZ character string is 1 byte longer than the declared length. The current length of the string is equal to the number of bytes before the first '00'x in the storage allocated to it. 2.6 X (hex) Character Constant The X character constant is a contiguous sequence of an even number of hex digits enclosed in single or double quotation marks and followed immediately by the letter X. Each pair of hex digits represents one character. The length of an X constant is half the number of hex digits specified. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 6

9 3 Arithmetic Data Declaration Terminology Keywords Attributes Base Scale Precision Length Vocabulary that Makes Up the PL/1 Language Descriptive properties of data. Radix of a value - DECIMAL or BINARY. Fixed-point or Floating-point. Number of digits in an arithmetic value. Number of characters in alphanumeric data or number of bits in a bit-string. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 7

10 3.1 Fixed Decimal Declare DCL DOLLARS_AND_CENTS FIXED DECIMAL (15,2); DCL PERCENT FIXED DECIMAL (7,4); DCL NET_PROFIT FIXED DEC (13,0); 3.2 Fixed Binary Declare DCL TABLE_INDEX FIXED BINARY (15,0); DCL VERY_HIGH_COUNTER FIXED BIN (31,0); CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 8

11 4 Floating Point Declaration DCL identifier FLOAT DECIMAL(p); Precision DCL SPEED FLOAT DECIMAL(6); This declare is used to reserve a floating point number with six significant digits being maintained. Since precision is less than seven digits, short form floating point is used - 4 bytes. DCL VERY_PRECISE_NUMBER FLOAT DEC(16); This declare is used to reserve a floating point number that requires more than 6 significant digits to be maintained. Sixteen digits of precision are reserved for this variable. Long form floating point is used - 8 bytes. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 9

12 5 Arithmetic Data Types in Review Data Type Use Precision Maximum Value Used for FIXED BINARY (15,0) (31,0) 32,767 2,147,483,647 Counting. Array indexing. Representing integers. FIXED DECIMAL (t,f) where: Up to 15 digits Numbers with fractional parts. FLOAT DECIMAL t=total digits f=fractional digits and t should be an odd 3 sizes: (6) Short (16) Long (33) Extended Data where total accuracy is required. Larger numbers; FIXED BINARY cannot be accommodated. 10**75 Extremely large or small numbers. Most modeling and scientific programming. Cconvenience. PL/1 will maintain the significant digits. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 10

13 6 Declaration of Strings Examples: DCL NAME CHAR(20); DCL TRUE BIT (1); DCL CITY CHARACTER(16); CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 11

14 7 Varying Length Strings Format: DCL NAME CHAR(30) {VARYING} {VAR} Strings may have the VARYING attribute. Allows the string to take on different lengths. Length can vary between 0 and maximum specified in DECLARE. PL/1 internally tracks the string length automatically. It uses 2 extra bytes (halfword binary) added to the front of the string's storage to store the length. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 12

15 8 Initial Attribute The initial attribute is used to give starting values to variables when storage is assigned. Format: Examples: DCL identifier attribute(s) {INITIAL} (value or expr.); {INIT} DCL NAME CHAR(10) DCL TOWN CHAR(20) DCL FALSE BIT(1) DCL ATTR BIT(4) INIT('ALBERT'); [padded with 4 blanks] VAR INIT ('AFTON'); [stores length] INIT ('O'B); INIT ('101101'B); [truncates rightmost 2 bits] DCL DOLLAR_AND_CENTS FIXED DEC(7,2) INIT ( ); DCL LARGE_NUMBER FLOAT DEC(16) INIT ( ); DCL RCD_COUNT FIXED BIN(15,0) INIT (9) or FIXED BIN(15,O) INIT (1001B); CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 13

16 9 String Data Data Type Stored Length CHARACTER_STRING 1 CHARACTER PER BYTE 0 TO CHAR's BIT_STRING 8 BITS PER BYTE 0 TO BITS DCL NAME CHAR(20), MASK BIT(17) String data may have the varying attribute, in which case the actual length at any particular time is the length of the last data item assigned to it. DCL NAME CHAR(20) VARYING; NAME = 'JON'; /*LENGTH IS 3 BYTES */ NAME = 'JONATHON'; /*LENGTH IS 8 BYTES */ Exercise: AVERAGE: PROCEDURE OPTIONS(MAIN); DECLARE (A,B,C,D,E) FIXED(4,1); GET LIST (A,B,C,D,E); MEAN = (A+B+C+D+E) / 5; PUT LIST('AVERAGE IS', MEAN); END AVERAGE; Explicitly Declared Identifiers Implicitly Declared Identifiers CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 14

17 10 Declaring Identifiers with the Bit Attribute DECLARE YES BIT(1), NO BIT(1), MORE_TRANSACTIONS BIT(1), SKILLS BIT(16); YES = '1'B; NO = '0'B; MORE_TRANSACTIONS = YES; SKILLS = ' 'B; SKILLS = (8)'0B' (8)'1'B; Pad on right with zeros, if bit-string is less than the declared length. Truncate on right, if bit-string is greater than the declared length. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 15

18 11 Initial Attribute The initial attribute causes an identifier to be set/initialized to a specified value before execution of other PL/1 statements in a program. DCL TITLE CHAR(10) INITIAL('SIT GEORGE'); DCL DELETE CHAR(1) INIT(' '); DCL SUM FIXED(5) INIT(0); DCL PI FIXED(6,5) INIT( ); /* NOTE ABBREVIATION */ DCL (A,B,C) FIXED(3) INIT(0); DCL ON BIT(1) INIT('1'B); DCL OFF BIT(1) INIT('0'B); CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 16

19 12 PICTURE Attribute The PICTURE attribute specifies the properties of a character data item by associating a picture character with each position of the data item Picture Character A picture character specifies a category of characters that can occupy that position. A numeric picture specification specifies arithmetic attributes of numeric character data in much the same way that they are specified by the appearance of a constant Numeric Character Numeric character data has an arithmetic value, but is stored in character form. Numeric character data is converted to coded arithmetic before arithmetic operations are performed. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 17

20 12.3 Picture Characters Character Description Additional Comment 9 Any decimal digit. V Virtual decimal point. Causes decimal point alignment.. Decimal point insert. Not necessarily related to decimal point alignment. - Negative. Usually used on output pictures. 9 Positive. Usually used on output pictures. S Sign--positive or negative. Used for input and output. X A Any alphanumeric character. Any alphabetic character. $ Insert dollar sign. 0 Insert asterisk., Insert comma. B Insert blank character. Usually used on output pictures. CR Credit symbol. cr for negative fields, bb for positive fields. DB Debit symbol. db for negative fields, bb for positive fields. Z Zero suppress. Input: blanks, interpreted as zeros, output: leading zeros replaced by blanks. / Insert slash. CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 18

21 Examples: Source Data Picture Specification Resulting Data '99999' 'ZZZZ9' '99V.99' 'ZZV.ZZ' 'ZZV.99' 'ZZ.V99' '9999V.99' 'ZZZZV.99' 'Z,ZZZV.99BBB' '99/99/99' 'Z9/99/99' 'ZZ/ZZ/ZZ(5)B' '$ZZZ,ZZZV.99' '$$$$,$$$V.99cr' '999V.99' 's999v.99' '999V.99BDB' '999V.99CR' '999V.99S' '(6)A' bbbb bbbbb bb.00 bbb b bb123.45bbb 07/07/84 b7/07/84 b7/b7/84bbbbb $bb1, bb$1,200.75bb bDB CR ABCbbb CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 19

22 13 Declare Statement Formats Examples: Format 1: DCL AMT_PURCH FIXED DEC(7,2) INIT(0); DCL AMT_COST FIXED DEC(7,2) INIT(0); DCL AMT_RECEIVED FIXED DEC(7,2) INIT(0); Format 2: DCL AMT_PURCH FIXED DEC(7,2) INIT(0), AMT_OF COST FIXED DEC(7,2) INIT(0), AMT_RECEIVED FIXED DEC(7,2) INIT(0); Format 3 (factoring): DCL (AMT_PURCH, AMT_COST, AMT_RECEIVED) FIXED DEC(7,2) INIT(0); Format 4 (factoring): DCL (AMT_PURCH INIT(300.00), AMT_COST INIT(250.00), AMT_RECEIVED INIT(0) FIXED DEC(7,2); CETi / COMPUTER EDUCATION TECHNIQUES, INC. (PL/1 Prg ) Ch 2: Page 20

DECLARING 2 DATA ITEMS AND REPRESENTATION

DECLARING 2 DATA ITEMS AND REPRESENTATION DELARING 2 DATA ITEMS AND REPRESENTATION hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Objectives You will learn: How to declare PL/I variables with scale, base and mode. Internal representation of numeric,

More information

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 INTRODUCTION. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 INTRODUCTION SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Facilities and features of PL/1. Structure of programs written in PL/1. Data types. Storage classes, control,

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Computer System and programming in C

Computer 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 information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These 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 information

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions CHAPTER 4 Operations On Data (Solutions to Odd-Numbered Problems) Review Questions 1. Arithmetic operations interpret bit patterns as numbers. Logical operations interpret each bit as a logical values

More information

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

UNIT 7A Data Representation: Numbers and Text. Digital Data UNIT 7A Data Representation: Numbers and Text 1 Digital Data 10010101011110101010110101001110 What does this binary sequence represent? It could be: an integer a floating point number text encoded with

More information

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic 0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

More information

The type of all data used in a C++ program must be specified

The type of all data used in a C++ program must be specified The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

More information

Introduction PL/1 Programming

Introduction PL/1 Programming Chapter 1: Introduction Performance Objectives You will learn: Facilities and features of PL/1. Structure of programs written in PL/1. Data types. Storage classes, control, and dynamic storage allocation.

More information

Data Storage and Query Answering. Data Storage and Disk Structure (4)

Data Storage and Query Answering. Data Storage and Disk Structure (4) Data Storage and Query Answering Data Storage and Disk Structure (4) Introduction We have introduced secondary storage devices, in particular disks. Disks use blocks as basic units of transfer and storage.

More information

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,... Chapter 9 Computer Arithmetic Reading: Section 9.1 on pp. 290-296 Computer Representation of Data Groups of two-state devices are used to represent data in a computer. In general, we say the states are

More information

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

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1 IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

More information

Characters, Strings, and Floats

Characters, Strings, and Floats Characters, Strings, and Floats CS 350: Computer Organization & Assembler Language Programming 9/6: pp.8,9; 9/28: Activity Q.6 A. Why? We need to represent textual characters in addition to numbers. Floating-point

More information

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng. CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits

More information

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE 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 information

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

More information

IBM 370 Basic Data Types

IBM 370 Basic Data Types IBM 370 Basic Data Types This lecture discusses the basic data types used on the IBM 370, 1. Two s complement binary numbers 2. EBCDIC (Extended Binary Coded Decimal Interchange Code) 3. Zoned Decimal

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java 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

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Programming in C++ 6. Floating point data types

Programming in C++ 6. Floating point data types Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction

More information

M1 Computers and Data

M1 Computers and Data M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

More information

Final Labs and Tutors

Final Labs and Tutors ICT106 Fundamentals of Computer Systems - Topic 2 REPRESENTATION AND STORAGE OF INFORMATION Reading: Linux Assembly Programming Language, Ch 2.4-2.9 and 3.6-3.8 Final Labs and Tutors Venue and time South

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

Unit 3. Constants and Expressions

Unit 3. Constants and Expressions 1 Unit 3 Constants and Expressions 2 Review C Integer Data Types Integer Types (signed by default unsigned with optional leading keyword) C Type Bytes Bits Signed Range Unsigned Range [unsigned] char 1

More information

unused unused unused unused unused unused

unused unused unused unused unused unused BCD numbers. In some applications, such as in the financial industry, the errors that can creep in due to converting numbers back and forth between decimal and binary is unacceptable. For these applications

More information

Programming Using C Homework 4

Programming Using C Homework 4 Programming Using C Homewk 4 1. In Homewk 3 you computed the histogram of an array, in which each entry represents one value of the array. We can generalize the histogram so that each entry, called a bin,

More information

Creating a procedural computer program using COBOL Level 2 Notes for City & Guilds 7540 Unit 005

Creating a procedural computer program using COBOL Level 2 Notes for City & Guilds 7540 Unit 005 Creating a procedural computer program using COBOL Level 2 Notes for City & Guilds 7540 Unit 005 Compatible with Micro Focus Net Express 5.0 COBOL compiler Version 1 Tench Computing Ltd Pines Glendale

More information

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-1 CHAPTER V CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-2 NUMBER SYSTEMS RADIX-R REPRESENTATION Decimal number expansion 73625 10 = ( 7 10 4 ) + ( 3 10 3 ) + ( 6 10 2 ) + ( 2 10 1 ) +(

More information

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

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Data Representation ti and Arithmetic for Computers Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Questions What do you know about

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

CHW 261: Logic Design

CHW 261: Logic Design CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Introduction to Computer Science-103. Midterm

Introduction to Computer Science-103. Midterm Introduction to Computer Science-103 Midterm 1. Convert the following hexadecimal and octal numbers to decimal without using a calculator, showing your work. (6%) a. (ABC.D) 16 2748.8125 b. (411) 8 265

More information

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

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

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers 198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information

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

Differentiate Between Keywords and Identifiers

Differentiate Between Keywords and Identifiers History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os)

More information

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B) Computer Arithmetic Data is manipulated by using the arithmetic instructions in digital computers. Data is manipulated to produce results necessary to give solution for the computation problems. The Addition,

More information

Computer Organization and Assembly Language. Lab Session 4

Computer Organization and Assembly Language. Lab Session 4 Lab Session 4 Objective: Learn how Data is represented in Assembly Language Introduction to Data Types and using different Data Types in Assembly language programs Theory: The basic machine data types

More information

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have

More information

Number Systems, Scalar Types, and Input and Output

Number Systems, Scalar Types, and Input and Output Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point

More information

Data Types. Data Types. Introduction. Data Types. Data Types. Data Types. Introduction

Data Types. Data Types. Introduction. Data Types. Data Types. Data Types. Introduction Introduction Primitive Composite Structured Abstract Introduction Introduction Data Type is a Collection of Data Objects Possible r-values for a memory cell Set of operations on those objects Descriptor

More information

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic 1 EE 109 Unit 19 IEEE 754 Floating Point Representation Floating Point Arithmetic 2 Floating Point Used to represent very small numbers (fractions) and very large numbers Avogadro s Number: +6.0247 * 10

More information

DEFINING DATA CONSTANTS AND SYMBOLS

DEFINING DATA CONSTANTS AND SYMBOLS Chapter 2 DEFINING DATA CONSTANTS AND SYMBOLS SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: Data types. Defining constants. Truncation and padding. Alignment - constants and boundary.

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right. Floating-point Arithmetic Reading: pp. 312-328 Floating-Point Representation Non-scientific floating point numbers: A non-integer can be represented as: 2 4 2 3 2 2 2 1 2 0.2-1 2-2 2-3 2-4 where you sum

More information

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning 3 Data Storage 3.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how

More information

VARIABLES AND CONSTANTS

VARIABLES AND CONSTANTS UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data

More information

LANGUAGE CONSTRUCTS AND CONVENTIONS IN VERILOG

LANGUAGE CONSTRUCTS AND CONVENTIONS IN VERILOG LANGUAGE CONSTRUCTS AND CONVENTIONS IN VERILOG Dr.K.Sivasankaran Associate Professor, VLSI Division School of Electronics Engineering, VIT University Outline White Space Operators Comments Identifiers

More information

Signed umbers. Sign/Magnitude otation

Signed umbers. Sign/Magnitude otation Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

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

Digital Fundamentals

Digital Fundamentals Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted

More information

Variable and Data Type I

Variable and Data Type I The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad February 18, 2017 Variable is reserved

More information

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Number Representation 2 1 Topics to be Discussed How are numeric data items actually

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

Digital Fundamentals

Digital Fundamentals Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Quiz 2 Agenda Lecture: Chapter 2 (2-7 through 2-11):

More information

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

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

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

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

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

The type of all data used in a C (or C++) program must be specified

The type of all data used in a C (or C++) program must be specified The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

More information

Objectives. Connecting with Computer Science 2

Objectives. Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn how numbering systems are used to count Understand the significance of positional value

More information

MC1601 Computer Organization

MC1601 Computer Organization MC1601 Computer Organization Unit 1 : Digital Fundamentals Lesson1 : Number Systems and Conversions (KSB) (MCA) (2009-12/ODD) (2009-10/1 A&B) Coverage - Lesson1 Shows how various data types found in digital

More information

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 1 CHAPTER TWO Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 2-1 Data Types 2-2 Complements 2-3 Fixed-Point Representation 2-4 Floating-Point Representation

More information

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

More information

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

CSC201, SECTION 002, Fall 2000: Homework Assignment #2 1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #2 DUE DATE Monday, October 2, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple

More information

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng. CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. CS 265 Midterm #1 Monday, Oct 18, 12:00pm-1:45pm, SCI 163 Questions on essential terms and concepts of Computer Architecture Mathematical questions on

More information

Declaration. Fundamental Data Types. Modifying the Basic Types. Basic Data Types. All variables must be declared before being used.

Declaration. Fundamental Data Types. Modifying the Basic Types. Basic Data Types. All variables must be declared before being used. Declaration Fundamental Data Types All variables must be declared before being used. Tells compiler to set aside an appropriate amount of space in memory to hold a value. Enables the compiler to perform

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

More information

CMU MSP 36601: Computer Hardware and Data Representation

CMU MSP 36601: Computer Hardware and Data Representation CMU MSP 36601: Computer Hardware and Data Representation H. Seltman, September 6, 2017 1. Warm-up in R a. > 0.1+0.1+0.1 == 0.3 [1] FALSE b. > 1e15+1e32 == 1e32 [1] TRUE c. > 1e-324 == 0 [1] TRUE d. > 1e-324

More information

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014 Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

More information

Chapter 4: Computer Codes. In this chapter you will learn about:

Chapter 4: Computer Codes. In this chapter you will learn about: Ref. Page Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence Ref. Page

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

Basic Elements of C. Staff Incharge: S.Sasirekha

Basic Elements of C. Staff Incharge: S.Sasirekha Basic Elements of C Staff Incharge: S.Sasirekha Basic Elements of C Character Set Identifiers & Keywords Constants Variables Data Types Declaration Expressions & Statements C Character Set Letters Uppercase

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

Numeric Variable Storage Pattern

Numeric Variable Storage Pattern Numeric Variable Storage Pattern Sreekanth Middela Srinivas Vanam Rahul Baddula Percept Pharma Services, Bridgewater, NJ ABSTRACT This paper presents the Storage pattern of Numeric Variables within the

More information

Data Representation and Storage. Some definitions (in C)

Data Representation and Storage. Some definitions (in C) Data Representation and Storage Learning Objectives Define the following terms (with respect to C): Object Declaration Definition Alias Fundamental type Derived type Use pointer arithmetic correctly Explain

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

Octal and Hexadecimal Integers

Octal and Hexadecimal Integers Octal and Hexadecimal Integers CS 350: Computer Organization & Assembler Language Programming A. Why? Octal and hexadecimal numbers are useful for abbreviating long bitstrings. Some operations on octal

More information

Variable and Data Type I

Variable and Data Type I Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store

More information

Number Systems. The Computer Works in Binary, or how I learned to think like a computer. The computer s natural number system is binary not decimal.

Number Systems. The Computer Works in Binary, or how I learned to think like a computer. The computer s natural number system is binary not decimal. PROGRAMMING CONCEPTS Number Systems The Computer Works in Binary, or how I learned to think like a computer Copyright 2013 Dan McElroy The computer s natural number system is binary not decimal. For example,

More information

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr Number Systems and Binary Arithmetic Quantitative Analysis II Professor Bob Orr Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information