Rounded option, COBOL Programming

Assignment Help:

ROUNDED OPTION:

Let us consider the DATA DIVISION entries which are as shown below:

1994_ROUNDED OPTION.png

Now, subsequent to the execution of the statement ADD A B GIVING C, the C will hold 58.6 rather than of 58.685 as  C can keep only one digit after the decimal point. Rather than that of this usual truncation, the rounding can be specified through the ROUNDED option. 

The ROUNDED option can be described as shown:

 

ADD        A             B            GIVING              C                ROUNDED

Now, the content of the C will be 58.7 rather than of 58.6.

It may be noted from the above illustration that whenever an arithmetic operation is executed, and if the number of places in the fractional part of the outcome happens to be bigger than the number of placed given for the fractional part in the receiving field, then truncation will occur.  Though, if the ROUNDED option is identified, 1 is added to the last digit whenever the most significant digit being thrown out is bigger than or equal to 5.  In the illustration shown here the most significant digit of the excess are 8 that is greater than 5. And hence, 1 has been added to the 6 that is the last digit of the receiving field. On another hand, if A and

B contains the 23.412 and 35.213 respectively, then both the statements

ADD        A             B            GIVING              C

and

ADD        A             B            GIVING              C                ROUNDED

will give the equivalent result and in both the cases C will have the value 58.6.

The ROUNDED option can be specified in the situation of any arithmetic verb by writing the word ROUNDED after the identifier, denoting the field which receives the result of the operation.  The ROUNDED phrases cannot be specified for the identifier which receives the remainder in the DIVIDE operation.


Related Discussions:- Rounded option

Program for indexed sequential file creation , PROGRAM FOR INDEXED SEQUENTI...

PROGRAM FOR INDEXED SEQUENTIAL FILE CREATION: We have to write a program to create an Indexed Sequential File in a dynamic mode for Student particulars. Suppose just 3 fields:

Redefines clause , REDEFINES CLAUSE: At times it may be found that two...

REDEFINES CLAUSE: At times it may be found that two or more storage regions defined in the DATA DIVISION are not in use concurrently. In such situations only one storage regio

Program for master file maintenance , PROGRAM FOR MASTER FILE MAINTENANCE: ...

PROGRAM FOR MASTER FILE MAINTENANCE: We have to write a program to keep the stu-file for which a record has just 2 fields,viz., rno(Roll Number) and name(Student Name). Give t

If statement - cobol programming, IF STATEMENT: The easiest form of th...

IF STATEMENT: The easiest form of the IF statement is  IF condition-1 statement-1 where the condition-1 may be any one from the shown below. When the condition-1

Rules for constructing an arithmetic expression, Rules for constructing an ...

Rules for constructing an Arithmetic Expression: The rules for constructing an arithmetic expression are as shown below: (i) When an arithmetic expression specifies a calcu

File-control entries for the sequential files, FILE-CONTROL ENTRIES FOR THE...

FILE-CONTROL ENTRIES FOR THE SEQUENTIAL FILES: The characteristics of each and every files handled in a program are specified in the ENVIRONMENT DIVISION and DATA DIVISION.

Rules of renames clause, RULES OF RENAMES CLAUSE:   The rules below s...

RULES OF RENAMES CLAUSE:   The rules below should be observed while using the RENAMES clause: (i) All RENAMES entries should be written only after the last record descript

Program for condition names , PROGRAM FOR CONDITION NAMES: We have to ...

PROGRAM FOR CONDITION NAMES: We have to write a simple program to demonstrate Condition names usage.  identification division.   program- id.   environment division.

Plus sign - edit characters for numeric data, Plus Sign - edit characters f...

Plus Sign - edit characters for numeric data: + (Plus Sign) : A plus sign is alike to minus sign except that when the item is positive, +sign will be inserted rather th

Rewrite statement - indexed files, REWRITE STATEMENT: As in the situat...

REWRITE STATEMENT: As in the situation of a relative file, the REWRITE statement needs that the file should be opened in the I-O mode, and if the SEQENTIAL access mode is spec

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd