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

Illustration of if- else statement, Illustration of if- else statement: ...

Illustration of if- else statement: IF OK-BALANCE NEXT SENTENCE ELSE MOVE 2 BALANCE-CODE In this illustration, the OK-BALANCE is a condition name. No action is specific if

Write statement, WRITE STATEMENT: The WRITE Statement verb releases a r...

WRITE STATEMENT: The WRITE Statement verb releases a record in an output file. The syntax for the WRITE statement can be unlike depending on the output device and the medium us

Example of compound condition, Example of compound condition: In commo...

Example of compound condition: In common, a compound condition has the form which is as shown below: Where condition-1 & condition-2 can be any one of the below:

Example of add verb, Example of add verb: (a) ADD A TO B. This illu...

Example of add verb: (a) ADD A TO B. This illustration represents that the value of A will be added to the value of B and the result will be stored in B.  The alignment of

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

Example of redefines clause, Example of Redefines clause: This illustr...

Example of Redefines clause: This illustration describes a sales record that may either contain the total amount of sale or the quantity (QTY) and UNIT-PRICE. The aim of such

Special-names - configuration section, SPECIAL-NAMES: This paragraph i...

SPECIAL-NAMES: This paragraph is used to associate some hardware names to the user-specified mnemonic names. This paragraph is elective in all compilers. The format of this pa

Close statement, CLOSE STATEMENT: When the processing of a file is com...

CLOSE STATEMENT: When the processing of a file is completed, then the file may be closed. This is completed with the help of the CLOSE-verb. The form of the CLOSE statement is

Environment division - cobol programming, Environment Division: The En...

Environment Division: The Environment Division is the second division in the COBOL source program. It is mainly machine-dependent . The computer and all the peripheral dev

Programming Assignment, I need help with a COBOL programming assingment. I ...

I need help with a COBOL programming assingment. I have started the program but I need help completing the program. I have 5 errors. Here is the question. 10. Suppose your company

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