gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [open-cobol-list] Re: Re: minor problem


From: William M. Klein
Subject: RE: [open-cobol-list] Re: Re: minor problem
Date: Thu Jul 29 14:53:05 2004

The first thing to say about this is that there is no such thing as a "bug"
in any result that the COMPUTE statement (or any other arithmetic
expression) yields - unless it isn't numeric.

Past, current (and future) Standards say that implementors may do anything
they want with an arithmetic expression (not an arithmetic statement) up to
and including issuing random numbers!!!  (The 2002 Standard introduces a NEW
option for "STANDARD ARITHMETIC" - but even that isn't the default and
doesn't apply to all statements).

Having said that, each implementor that I know of uses different rules for
"intermediate results".  For the most recent IBM mainframe compiler,
Enterprise COBOL V3R3, the *LENGTHY* rules are defined at:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG20/APPENDIX
1.1 

However, you should NOT think these are even the same results across IBM
mainframe compilers.  Consider (for example) that Micro Focus (that SPENDS
lots of money and resources on IBM emulation) includes the following
directives:

"ARITHMETIC 

Specifies how arithmetic expressions are to be evaluated.

Syntax:
>>-.---.--ARITHMETIC--"arith-type"---------><
   +-/-+

Parameters:
arith-type The behavior to adopt: 

        ENTCOBOL Truncate according to the rules of Enterprise COBOL for
z/OS and OS/390.  

        MF Do not truncate intermediate results. With ARITHMETIC"MF"
specified, expressions are calculated as accurately as possible because no
truncation takes place. 

        OS390 Truncate according to the rules of COBOL for OS/390.  

        OSVS Truncate according to the rules of OS/VS COBOL.  

        TRUNC20 Truncate the number of digits to the right of the decimal
point to 20 at each step of the evaluation of the expression. This provides
similar results to the truncation provided in COBOL Workbench. You should
only use this directive if you need to obtain evaluation results similar to
those provided in COBOL Workbench. If you specify TRUNC20, you must not
change the setting of the INTLEVEL Compiler directive from its default value
of 2. This means that you cannot use some of the newer features, such as
numeric pictures with more than 18 total digits, with the TRUNC20 parameter.


        VSC2 Truncate according to the rules of VS COBOL II and COBOL/370. "

See:
 
http://supportline.microfocus.com/supportline/documentation/books/sx40/sx40i
ndx.htm 

  ***

It *might* be nice to implement the ISO 2002 Rules for "Standard Arithmetic"
- but my personal opinion (and I could be mistaken) is that when these are
in effect the average compute statement will take long enough to "raise a
family of 5" <G>
 

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On 
> Behalf Of David Korn
> Sent: Thursday, July 29, 2004 11:48 AM
> To: address@hidden
> Cc: address@hidden
> Subject: [open-cobol-list] Re: Re: minor problem
> 
> The following program
> ******************************** Top of Data ******************
>       IDENTIFICATION DIVISION.
>       PROGRAM-ID. PROG29.
>       DATA DIVISION.
>       WORKING-STORAGE SECTION.
>       01  WS-MEMBER-COUNT         PIC 9(5) COMP.
>       PROCEDURE DIVISION.
>               MOVE 680 TO WS-MEMBER-COUNT.
>               COMPUTE WS-MEMBER-COUNT=
>               (WS-MEMBER-COUNT / 4096) * 4096 + 4096
>               DISPLAY 'WS-MEMBER-COUNT=' WS-MEMBER-COUNT
>               GOBACK.
> ******************************* Bottom of Data ****************
> outputs
> WS-MEMBER-COUNT=0000004096
> with the MVS compiler and
> WS-MEMBER-COUNT=0000004776
> with OpenCobol.
> 
> Is this a bug in OpenCobol?  If so, where is the fix?
> 
> David Korn
> address@hidden
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by OSTG. Have you noticed the 
> changes on
> Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
> one more big change to announce. We are now OSTG- Open Source 
> Technology
> Group. Come see the changes on the new OSTG site. www.ostg.com
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]