Rounded option, COBOL Programming

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.

Posted Date: 10/17/2012 1:24:27 AM | Location : United States







Related Discussions:- Rounded option, Assignment Help, Ask Question on Rounded option, Get Answer, Expert's Help, Rounded option Discussions

Write discussion on Rounded option
Your posts are moderated
Related Questions
PROGRAM USING OCCURS CLAUSE: We have to write a simple program to demonstrate Occurs Clause. Get the employee details for 3 persons and compute the total salary. identifica

PROGRAM FOR ADD VERB: We have to write a simple program to elaborate the ADD verb. You can also use edit characters in the program. Identification division. Program- id.

Object-Computer - Configuration section: The computer name specifies a specific computer on which the object program is to be executed. The MEMORY SIZE is used to show the

PICTURE specification: The size of a group item is equivalent to the total of the sizes of all the subordinate elementary items. The group item class is alphanumeric. The i

Illustration of Divide verb: (a) DIVIDE 5 INTO A. If the value of A is 20, then after execution of this statement the value of A will be 4. The older value of A will be los

MULTIPLY VERB:   The Multiply Verb causes one or more multiplicands to be multiplied by the multiplier and to store the products. The form of the MULTIPLY verb is as shown be

CR and DB (Credit and Debit Sign): The two characters that is CR or DB symbol may appear only at the rightmost place of the picture. They are similar to the minus sign edit ch

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:

PROGRAM FOR IF -ELSE: We have to write a program to check whether the given number is ODD or EVEN. You can use IF..ELSE. Identification division. Program- id. IfElse.

RULES OF MOVE VERB:  The Data movement is managed by the rules which are as shown below: (a) The contents of the identifier - 1 or the value of the literal - 1 is moved to