Arithmetic and Edited Pictures. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal.

Slides:



Advertisements
Similar presentations
Spreadsheets A spreadsheet package is a general purpose computer package that is designed to perform calculations. A spreadsheet is a table which is divided.
Advertisements

6-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Binary Addition Rules Adding Binary Numbers = = 1
Physics Rules for using Significant Figures. Rules for Averaging Trials Determine the average of the trials using a calculator Determine the uncertainty.
© 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5/e Starting Out with C++: Early Objects 5 th Edition Chapter 2 Introduction.
The Decimal Number System
Pseudocode.
Skills for Success: Excel Association of Soil & Water Conservation Districts Summer Conference By: Darci Harrison.
7.1 - Introduction To Signed Numbers
Significant Figures.  All measurements are inaccurate  Precision of measuring device  Human error  Faulty technique.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Programming in COBOL-85 For IBM Mainframe System 390
Computer Arithmetic Nizamettin AYDIN
PRESENTATION 1 Whole Numbers. PLACE VALUE The value of any digit depends on its place value Place value is based on multiples of 10 as follows: UNITS.
IT253: Computer Organization
10/2/20151 Significant Figures CEC. 10/2/20152 Why we need significant figures In every measurement in a lab, there are inherent errors. No measurement.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Agenda Reporting Work on Assignment 4! Printing on power systems.
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
COBOL Basics 2. H E N N E S S Y R M L M F Group Items/Records StudentDetails WORKING-STORAGE SECTION. 01StudentDetailsPIC X(26).
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
To familiarize you with  Options of MOVE statement  Rules for moving fields and literals  Printing edit symbols  Designing and printing reports 1.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
Move and Edited Output1 NON-NUMERIC: Left justify the data in the memory location. If the length of the data is smaller than the length of the field (as.
Module 6 Arithmetic. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal. ADD.
Lecture 61 Editted Output Editing Functions –Two broad classes : A) insertion and B) replacement and suppression 1.Printing decimal points 2.Suppressing.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
Chapter 2 Variables.
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
Warm-Up Find the value of each expression − (1.9) ÷ 0.3 Which One Doesn’t Belong? (Include your reasoning…)
COMPETENCY #2 Laws of Exponents Scientific Notation.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions Chapter 7.
Chemistry: An Introduction to General, Organic, and Biological Chemistry, Eleventh Edition Copyright © 2012 by Pearson Education, Inc. Chapter 1 Chemistry.
Addition, Subtraction, Multiplication, Division by a whole number, and Division by a decimal.
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Gator Engineering Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
Any Questions! 2 Agenda Moving data Arithmetic Verbs Compute statement.
Significant Figures. Significant Figure Rules 1) ALL non-zero numbers (1,2,3,4,5,6,7,8,9) are ALWAYS significant. 1) ALL non-zero numbers (1,2,3,4,5,6,7,8,9)
 Scientific notation is simply a method for expressing, and working with, very large or very small numbers. It is a short hand method for writing numbers,
Significant Figures Box and Dot Method. Step 1  Draw a box around all nonzero digits, beginning with the leftmost nonzero digit and ending with the rightmost.
6-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Introduction To Number Systems
Significant Figures Box and Dot Method.
5.2 The Integers.
Multiplying and Dividing Decimals by 10, 100, and 1,000
Scientific Notation.
Arithmetic Operator Operation Example + addition x + y
Significant Figures
Multiplying and Dividing Decimals by 10, 100, and 1,000
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Multiplying and Dividing Decimals by 10, 100, and 1,000
Presentation transcript:

Arithmetic and Edited Pictures

Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal. ADD Males TO Females GIVING TotalStudents. SUBTRACT Tax FROM GrossPay. SUBTRACT Tax FROM GrossPay GIVING NetPay. DIVIDE Total BY Members GIVING MemberAverage. DIVIDE Members INTO Total GIVING MemberAverage. MULTIPLY 10 BY Magnitude. MULTIPLY Members BY Subs GIVING TotalSubs.  The exceptions are the COMPUTE and the DIVIDE with REMAINDER.

The ROUNDED option Receiving FieldActual ResultTruncated ResultRounded Result PIC 9(3)V PIC 9(3)  The ROUNDED option takes effect when, after decimal point alignment, the result calculated must be truncated on the right hand side.  The option adds 1 to the receiving item when the leftmost truncated digit has an absolute value of 5 or greater.

 A size error condition exists when, after decimal point alignment, the result is truncated on either the left or the right hand side.  If an arithmetic statement has a rounded phrase then a size error only occurs if there is truncation on the left hand side (most significant digits). Receiving FieldActual ResultSIZE ERROR PIC 9(3)V PIC 9(3)V PIC 9(3).124 PIC 9(3).1246 PIC 9(3)V9 Not Rounded PIC 9(3)V9 Rounded PIC 9(3)V9 Rounded The ON SIZE ERROR option YesYesNoYesYesNoYes

ADD Examples ADD Cash TO Total. Before Before After ADD Cash, 20 TO Total, Wage. Before Before After ADD Cash, Total GIVING Result. Before Before After ADD Males TO Females GIVING TotalStudents. Before Before After ADD Cash TO Total. Before Before After ADD Cash, 20 TO Total, Wage. Before Before After ADD Cash, Total GIVING Result. Before Before After ADD Males TO Females GIVING TotalStudents. Before Before After

SUBTRACT Examples SUBTRACT Tax FROM GrossPay, Total. Before Before After SUBTRACT Tax, 80 FROM Total. Before Before After SUBTRACT Tax FROM GrossPay GIVING NetPay. Before Before After SUBTRACT Tax FROM GrossPay, Total. Before Before After SUBTRACT Tax, 80 FROM Total. Before Before After SUBTRACT Tax FROM GrossPay GIVING NetPay. Before Before After

MULTIPLY and DIVIDE Examples MULTIPLY Subs BY Members GIVING TotalSubs ON SIZE ERROR DISPLAY "TotalSubs too small" END-MULTIPLY. Subs Members TotalSubs Subs Members TotalSubs Before Before After MULTIPLY 10 BY Magnitude, Size. Before Before After DIVIDE Total BY Members GIVING Average ROUNDED. Before Before After MULTIPLY Subs BY Members GIVING TotalSubs ON SIZE ERROR DISPLAY "TotalSubs too small" END-MULTIPLY. Subs Members TotalSubs Subs Members TotalSubs Before Before After MULTIPLY 10 BY Magnitude, Size. Before Before After DIVIDE Total BY Members GIVING Average ROUNDED. Before Before After

The Divide Exception DIVIDE 201 BY 10 GIVING Quotient REMAINDER Remain. Before Before After DIVIDE 201 BY 10 GIVING Quotient REMAINDER Remain. Before Before After

Compute IrishPrice = SterlingPrice / Rate * 100. Before Before After Compute IrishPrice = SterlingPrice / Rate * 100. Before Before After The COMPUTE Precedence Rules. Precedence Rules. 1.** 1.**=POWERN N 2.* / 2.*= MULTIPLYx /=DIVIDE÷ =ADD+ -=SUBTRACT- Precedence Rules. Precedence Rules. 1.** 1.**=POWERN N 2.* / 2.*= MULTIPLYx /=DIVIDE÷ =ADD+ -=SUBTRACT-

Edited Pictures.  Edited Pictures are PICTURE clauses which format data intended for output to screen or printer.  To enable the data items to be formatted in a particular style COBOL provides additional picture symbols supplementing the basic 9, X, A, V and S symbols.  The additional symbols are referred to as “Edit Symbols” and PICTURE clauses which include edit symbols are called “Edited Pictures”.  The term edit is used because the edit symbols have the effect of changing, or editing, the data inserted into the edited item.  Edited items can not be used as operands in a computation but they may be used as the result or destination of a computation (i.e. to the right of the word GIVING).

Editing Types  COBOL provides two basic types of editing  Insertion Editing - which modifies a value by including additional items.  Suppression and Replacement Editing - which suppresses and replaces leading zeros.  Each type has sub-categories Insertion editing  Simple Insertion  Special Insertion  Fixed Insertion  Floating Insertion Insertion editing  Simple Insertion  Special Insertion  Fixed Insertion  Floating Insertion Suppression and Replacement  Zero suppression and replacement with spaces  Zero suppression and replacement with asterisks Suppression and Replacement  Zero suppression and replacement with spaces  Zero suppression and replacement with asterisks

Editing Symbols, B 0 / Simple Insertion. Special Insertion + - CR DB $ Fixed Insertion + - S Floating Insertion Z * Suppression and Replacement, B 0 / Simple Insertion. Special Insertion + - CR DB $ Fixed Insertion + - S Floating Insertion Z * Suppression and Replacement Edit Symbol Editing Type

Simple Insertion. Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC PIC 999,999 PIC 9(6)000078PIC 9(3),9(3) PIC 9(6)000078PIC ZZZ,ZZZ PIC 9(6)000178PIC ***,*** PIC 9(6)002178PIC ***,*** PIC 9(6)120183PIC 99B99B99 PIC 9(6)120183PIC 99/99/99 PIC 9(6) PIC Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC PIC 999,999 PIC 9(6)000078PIC 9(3),9(3) PIC 9(6)000078PIC ZZZ,ZZZ PIC 9(6)000178PIC ***,*** PIC 9(6)002178PIC ***,*** PIC 9(6)120183PIC 99B99B99 PIC 9(6)120183PIC 99/99/99 PIC 9(6) PIC , ,078 78****178 **2,178 120183 12/01/

Special Insertion. Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 999V PIC PIC 999V PIC PIC 999V PIC PIC PIC Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 999V PIC PIC 999V PIC PIC 999V PIC PIC PIC

Fixed Insertion - Plus and Minus. Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC S PIC -999 PIC S PIC 999- PIC S PIC -999 PIC S9(5)+12345PIC +9(5) PIC S9(3)-123PIC +9(3) PIC S9(3)-123PIC 999+ Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC S PIC -999 PIC S PIC 999- PIC S PIC -999 PIC S9(5)+12345PIC +9(5) PIC S9(3)-123PIC +9(3) PIC S9(3)-123PIC 123 

Fixed Insertion - Credit, Debit, $ Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC S9(4)+1234PIC 9(4)CR PIC S9(4)-1234PIC 9(4)CR PIC S9(4)+1234PIC 9(4)DB PIC S9(4)-1234PIC 9(4)DB PIC 9(4)1234PIC $99999 PIC 9(4)0000PIC $ZZZZZ Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC S9(4)+1234PIC 9(4)CR PIC S9(4)-1234PIC 9(4)CR PIC S9(4)+1234PIC 9(4)DB PIC S9(4)-1234PIC 9(4)DB PIC 9(4)1234PIC $99999 PIC 9(4)0000PIC $ZZZZZ 1234 1234CR 1223 1234DB $01234 $

Floating Insertion. Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 9(4) 0000PIC $$,$$9.99 PIC 9(4) 0080PIC $$,$$9.00 PIC 9(4) 0128PIC $$,$$9.99 PIC 9(5) 57397PIC $$,$$9 PIC S9(4)- 0005PIC PIC S9(4)+0080PIC PIC S9(4)- 0080PIC PIC S9(5)+71234PIC Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 9(4) 0000PIC $$,$$9.99 PIC 9(4) 0080PIC $$,$$9.00 PIC 9(4) 0128PIC $$,$$9.99 PIC 9(5) 57397PIC $$,$$9 PIC S9(4)- 0005PIC PIC S9(4)+0080PIC PIC S9(4)- 0080PIC PIC S9(5)+71234PIC $0.00 $0.00 $80.00 $80.00 $ $ $7, ž1234 ž1234

Suppression and Replacement Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 9(5)12345PIC ZZ,999 PIC 9(5)01234PIC ZZ,999 PIC 9(5)00123PIC ZZ,999 PIC 9(5)00012PIC ZZ,999 PIC 9(5)05678PIC **,**9 PIC 9(5)00567PIC **,**9 PIC 9(5)00000PIC **,*** Sending Receiving Sending Receiving Picture Data Picture Result Picture Data Picture Result PIC 9(5)12345PIC ZZ,999 PIC 9(5)01234PIC ZZ,999 PIC 9(5)00123PIC ZZ,999 PIC 9(5)00012PIC ZZ,999 PIC 9(5)05678PIC **,**9 PIC 9(5)00567PIC **,**9 PIC 9(5)00000PIC **,*** 12,345 1,234 123 012 *5,678 ***567 ******