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
RELATIVE FILES: The Files that are stored on a direct access storage medium like magnetic disk are frequently known as direct access files. The COBOL supports three different

Transaction file : A transaction file is a file which contains new records those changes to old records which are used to update the master file. The problem of file updatio

Examples - Edit characters for numeric data: The following illustration illustrates the use of Z editing characters. The character b is used to indicate the space character an

Non numeric: The nonnumeric literal is used in normal to output messages or headings. The Characters which are enclosed between " " constitute nonnumeric literal. The maximum

Introduction to COBOL: In the year 1959, a new language named the COBOL ( CO mmon B usiness O riented L anguage) was introduced remembering the business purpose application

, (Comma) : A comma, whenever used in a picture, is considered as an insertion character and inserted wherever it become visible. There can be more than one comma in the pictu

CLASS CONDITION:   The class condition establishes whether or not the value of the operand is numeric or alphabetic. The operand is numeric if it contains only the digits 0 t

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

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 Description for the Relative and Indexed Files: The FD entry for a relative or an indexed file is similar to that of a sequential file. Some compilers do not permit varia