[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cobol

Title:VAX/DEC COBOL
Notice:Kit,doc,performance talk info-->DIR/KEY=KIT or DOC or PERF_TALK
Moderator:PACKED::BRAFFITT
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3250
Total number of notes:13077

3217.0. "Rounding problem with IEEE floats" by KERNEL::BIRKINSHAW (Press Enter to Exit) Fri Mar 14 1997 13:41

Cobol 2.4


I may be misunderstanding this but the following program and output
when compiled with /float=IEEE gives rounding errors. The customer
brought it to my attention when his customers found they were
giving away 50p on each transaction they did. I assumed this would
be a dfloat problem but when he told me he was compiling with IEEE
I got confused. Can anyone help?
 

program-id.  rounding_error.

data division.
working-storage section.
01  f1                    comp-2.
01  f2                    comp-2.
01  f3                    pic ----9.99.

procedure division.
main section.
P1.

        display " ".
        display "In COBOL Main program".

        move 1.00 to f1.
        move 1.00 to f2.
        subtract 0.00 from f1 rounded
        subtract 0.00 from f2 rounded
        move f1 to f3.
        display "f3 with move = " f3.
        compute f3 rounded = f2.
        display "f3 with compute = " f3.
        stop run.

Output

In COBOL Main program
f3 with move =     1.50
f3 with compute =     1.50
$

T.RTitleUserPersonal
Name
DateLines
3217.1xrefKERNEL::BIRKINSHAWPress Enter to ExitFri Mar 14 1997 15:246
This is the same problem for the same custoemr as discussed in 
note 581 of DEC_COBOL_IFT. And I see I forgot to mention that
the problem is confined to alpha in my base note.

regards
Simon
3217.2From CLT::DEC_COBOL_IFT 581PACKED::BRAFFITTFri Mar 14 1997 16:3396
       <<< CLT::DISK$CLT_LIBRARY3:[NOTES$LIBRARY]DEC_COBOL_IFT.NOTE;1 >>>
             -< DEC COBOL notes [kits/docs - 2, performance - 7] >-
================================================================================
Note 581.0       ROUNDED clause gives incorrect results on Alpha         1 reply
KZIN::HUDSON "That's what I think"                   90 lines  14-MAR-1997 10:43
--------------------------------------------------------------------------------
There is a difference in behaviour between VAX and Alpha for the following
program, and I believe ALpha is incorrect.

The customer reported this problem with 2.3 of the compiler, but trying on 2.4
makes no difference.

Previous errors that the customer saw with ROUNDED were fixed with 2.3, but
this program still sees problems:

Thanks for any comments

nick

================================================================================
identification division.

program-id. cobol_bug_test.
data division.

working-storage section.
01	work_no	comp-2 value	0.00.
01	disp_1 pic ------9.99.

procedure division.
main section.
p1.
	display " ".
	display "Cobol v2.3 'subtract' test. v2 - a selection of simple tests".
	display " ".
	display " ".
	display " ".

	move	1.00 to work_no.
	subtract 0.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 0.00 from 1.00 rounded gives " disp_1.

	move 10.00 to work_no.
	subtract 0.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 0.00 from 10.00 rounded gives " disp_1.

	move -10.00 to work_no.
	subtract 0.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 0.00 from -10.00 rounded gives " disp_1.

	move 1.00 to work_no.
	subtract 5.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 5.00 from 1.00 rounded gives " disp_1.

	move 10.00 to work_no.
	subtract -5.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 5.00 from 10.00 rounded gives " disp_1.

	move -10.00 to work_no.
	subtract 30.00 from work_no rounded
	move work_no to disp_1.
	display "subtract 30.00 from -10.00 rounded gives " disp_1.
================================================================================

Alpha:

Cobol v2.3 'subtract' test. v2 - a selection of simple tests



subtract 0.00 from 1.00 rounded gives       1.50
subtract 0.00 from 10.00 rounded gives      10.50
subtract 0.00 from -10.00 rounded gives     -10.50
subtract 5.00 from 1.00 rounded gives      -4.50
subtract 5.00 from 10.00 rounded gives      15.50
subtract 30.00 from -10.00 rounded gives     -40.50


VAX:

Cobol v2.3 'subtract' test. v2 - a selection of simple tests



subtract 0.00 from 1.00 rounded gives       1.00
subtract 0.00 from 10.00 rounded gives      10.00
subtract 0.00 from -10.00 rounded gives     -10.00
subtract 5.00 from 1.00 rounded gives      -4.00
subtract 5.00 from 10.00 rounded gives      15.00
subtract 30.00 from -10.00 rounded gives     -40.00

3217.3see note 3212PACKED::BRAFFITTFri Mar 14 1997 16:454
    Both programs use COMP-2.  COMP-2 results are not identical between
    VAX and Alpha.
    
    Some details are in note 3212.
3217.4Bug - workaroundDJS::SZYMANSKIFri Mar 14 1997 18:076
Looks like a bug to me.  Rewriting the SUBTRACT as the equivalent COMPUTE
statement produces the expected result, i.e. where
    subtract 0 from f1 rounded
gets the result 1.5,
    compute f1 rounded = f1 - 0.0
gets the result 1.0.
3217.5KERNEL::BIRKINSHAWPress Enter to ExitMon Mar 17 1997 08:175
I agree it's a bug, but unfortunately the workaround wouldn't be
acceptable. The customer has several hundred thousand lines of 
code which would need to be hand-checked and changed. They are
tearing their hair out over this one and we need a quick fix.
Looks like IPMT time.
3217.6WIBBIN::NOYCEPulling weeds, pickin' stonesMon Mar 17 1997 14:093
Don, this is not a case of "COMP-2 results don't always match."
This is a bug.  Floating-point operations with ROUNDED seem to be adding
an extra 0.5 (with appropriate sign), which they should not be doing.
3217.7when's the fix ?KERNEL::SMITHTue Mar 18 1997 09:027
    
    Do you have an inkling as to when a workaround might be available ?
    
    Thanks and regards
    ewan smith - UK CSC.
    
    
3217.8COMPUTE is the only temporary workaround identified so farPACKED::BRAFFITTTue Mar 18 1997 10:3017
>    Do you have an inkling as to when a workaround might be available ?
    
This is the only temporary workaround that has been identified so far.
        
           <<< CLT::DISK$CLT_LIBRARY3:[NOTES$LIBRARY]COBOL.NOTE;1 >>>
                               -< VAX/DEC COBOL >-
================================================================================
Note 3217.4             Rounding problem with IEEE floats                 4 of 7
DJS::SZYMANSKI                                        6 lines  14-MAR-1997 15:07
                             -< Bug - workaround >-
--------------------------------------------------------------------------------
Looks like a bug to me.  Rewriting the SUBTRACT as the equivalent COMPUTE
statement produces the expected result, i.e. where
    subtract 0 from f1 rounded
gets the result 1.5,
    compute f1 rounded = f1 - 0.0
gets the result 1.0.
3217.9We are testing a potential fixPACKED::BRAFFITTWed Mar 19 1997 18:3948
From:	PACKED::BRAFFITT "19-Mar-1997 1404" 19-MAR-1997 14:05:27.18
To:	FIXCLD::SDT_ACE
CC:	BRAFFITT
Subj:	UPDATE UVO105254

RE: CLD UVO105254
    CLT::COBOL note 3217
    DEC COBOL - ADD/SUBTRACT/MULTIPLY/DIVIDE ROUNDED with COMP-1 and COMP-2

>UVO105254 RC     UN     2     BLOTCKY      DEC COBOL       T    0   17-MAR-1997
>On Alpha DEC Cobol 2.4 IEEE format floats are incorrectly rounded              
>Alias: CFS.49745                               
>Customer company: BYTEL           
>NORTHGATE HSE 1A STOKE ROAD          SLOUGH

We are testing a potential fix for this problem.  If our one week of regression
testing goes well, we should have a compiler image for OpenVMS Alpha for you to
copy for the customer to try next THU morning (26-March).

We are considering a DEC COBOL V2.4 TIMA kit for OpenVMS Alpha for late April
or early May, and this compiler fix would be included in that TIMA kit.

The reported problem is present in all currently supported versions of DEC
COBOL (i.e. V2.3 and V2.4).

The problem does not impact COMPUTE, so the temporary workaround with DEC COBOL
V2.3 SSB and V2.4 SSB compilers is to

	replace
	 ADD/SUBTRACT/MULTIPLY/DIVIDE ROUNDED	destination COMP-1 or COMP-2

	with an equivalent
	 COMPUTE                      ROUNDED 	destination COMP-1 or COMP-2

Even with this compiler fix, COMP-2 (which defaults to D float with VAX COBOL
and DEC COBOL) is not 100% compatible between VAX and Alpha.  This is
documented in the Alpha Architecture Manual and in the DEC COBOL User Manual
Compatibility Appendix (section B.3.7 p. B-17).

Release note:

2.4-906	  A compiler problem has been corrected where ADD, SUBTRACT,
	  MULTIPLY, and DIVIDE with a floating-point destination
	  (COMP-1 or COMP-2) and the ROUNDED option could result in
	  a wrong answer.

- Don Braffitt
  DEC/VAX COBOL project leader
3217.9We are testing a potential fixPACKED::BRAFFITTThu Mar 20 1997 12:2264
From:	SPSEG::SDT_ACE "20-Mar-1997 0916 -0500" 20-MAR-1997 09:20:10.46
To:	,cc: Distribution list
CC:	
Subj:	An update on Case UVO105254 (On Alpha DEC Cobol 2.4 IEEE format floats are incorrectly rounded)

[This update was sent from BRAFFITT on 20-MAR-1997 09:16:49.12]
[SDT Support responsible for next action, Problem is undefined]

----------------
The following error message was returned whilst sending to
 address FIXCLD::SDT_ACE

    %NMAIL-E-LOGLINK, error creating network link to node FIXCLD
    -SYSTEM-F-INVLOGIN, login information invalid at remote node

This is a soft error, but the message has been cancelled.
No more attempts to send to this address will be made.

----------------
The text of your failed mail message follows:

RE: CLD UVO105254
    CLT::COBOL note 3217
    DEC COBOL - ADD/SUBTRACT/MULTIPLY/DIVIDE ROUNDED with COMP-1 and COMP-2

>UVO105254 RC     UN     2     BLOTCKY      DEC COBOL       T    0   17-MAR-1997
>On Alpha DEC Cobol 2.4 IEEE format floats are incorrectly rounded
>Alias: CFS.49745
>Customer company: BYTEL
>NORTHGATE HSE 1A STOKE ROAD          SLOUGH

We are testing a potential fix for this problem.  If our one week of regression
testing goes well, we should have a compiler image for OpenVMS Alpha for you to
copy for the customer to try next WED morning (26-March).

We are considering a DEC COBOL V2.4 TIMA kit for OpenVMS Alpha for late April
or early May, and this compiler fix would be included in that TIMA kit.

The reported problem is present in all currently supported versions of DEC
COBOL (i.e. V2.3 and V2.4).

The problem does not impact COMPUTE, so the temporary workaround with DEC COBOL
V2.3 SSB and V2.4 SSB compilers is to

	replace
	 ADD/SUBTRACT/MULTIPLY/DIVIDE ROUNDED	destination COMP-1 or COMP-2

	with an equivalent
	 COMPUTE                      ROUNDED 	destination COMP-1 or COMP-2

Even with this compiler fix, COMP-2 (which defaults to D float with VAX COBOL
and DEC COBOL) is not 100% compatible between VAX and Alpha.  This is
documented in the Alpha Architecture Manual and in the DEC COBOL User Manual
Compatibility Appendix (section B.3.7 p. B-17).

Release note:

2.4-906	  A compiler problem has been corrected where ADD, SUBTRACT,
	  MULTIPLY, and DIVIDE with a floating-point destination
	  (COMP-1 or COMP-2) and the ROUNDED option could result in
	  a wrong answer.

- Don Braffitt
  DEC/VAX COBOL project leader
3217.10Update sent on case - fixed with 2.4-906 compilerPACKED::BRAFFITTMon Mar 24 1997 10:1073
From:	SPSEG::SDT_ACE "24-Mar-1997 0651 -0500" 24-MAR-1997 06:53:45.51
To:	,cc: Distribution list
CC:	
Subj:	An update on Case UVO105254 (On Alpha DEC Cobol 2.4 IEEE format floats are incorrectly rounded)

[This update was sent from BRAFFITT on 24-MAR-1997 06:51:05.45]
[SDT Support responsible for next action, Problem is undefined]

CLOSE UVO105254/CODE=FN/FIXREL=2.5/DESIGN=YES/COMPLEX=YES/AVAILABLE=YES
	/TIMING=C/VALID=C

RE: CLD UVO105254
    CLT::COBOL note 3217
    DEC COBOL - ADD/SUBTRACT/MULTIPLY/DIVIDE ROUNDED with COMP-1 and COMP-2

>UVO105254 RC     UN     2     BLOTCKY      DEC COBOL       T    0   17-MAR-1997
>On Alpha DEC Cobol 2.4 IEEE format floats are incorrectly rounded
>Alias: CFS.49745
>Customer company: BYTEL
>NORTHGATE HSE 1A STOKE ROAD          SLOUGH

We have a compiler fix for this problem.  We plan to make the fix available
with DEC COBOL V2.5.  In addition, we have a built an updated DEC COBOL 2.4
compiler for OpenVMS Alpha with the fix that we would like you to give to the
customer to evaluate:

  ******************************
  Directory CLT::CLT$LIBRARY:[DEC_COBOL]

  COBOL.EXE;906         10449  19-MAR-1997 12:05:29.00

This updated compiler is available for all versions of OpenVMS Alpha currently
supported by DEC COBOL V2.4 and can be given to any customer with a valid DEC
COBOL service contract for those versions of OpenVMS Alpha:

  ******************************
  CLT::CLT$LIBRARY:[DEC_COBOL]DEC_COBOL_SPD_VMS_V24.TXT;1

  SOFTWARE REQUIREMENTS
  OpenVMS Alpha Operating System Version 6.1-Version 7.0 (SPD 25.01.xx)

We are considering a DEC COBOL TIMA kit for OpenVMS Alpha for late April or
early May, and this compiler fix would be included in that TIMA kit.

The problem does not impact COMPUTE.  There are three known temporary
workarounds with DEC COBOL compilers prior to 2.4-906 for customers who choose
not to use this updated compiler:

	Remove ROUNDED option where redundant
	Rewrite format 1 ADD,SUBTRACT,MULTIPLY,DIVIDE as format 2
	Rewrite format 1 ADD,SUBTRACT,MULTIPLY,DIVIDE as COMPUTE:
	  replace
	   ADD,SUBTRACT,MULTIPLY,DIVIDE ROUNDED	destination COMP-1 or COMP-2
	  with an equivalent
	   COMPUTE                      ROUNDED destination COMP-1 or COMP-2

Even with this compiler fix, COMP-2 (which defaults to D float with VAX COBOL
and DEC COBOL) is not 100% compatible between VAX and Alpha.  This is
documented in the Alpha Architecture Manual and in the DEC COBOL User Manual
Compatibility Appendix (section B.3.7 p. B-17).

Release note:

2.4-906	  A compiler problem has been corrected where ADD, SUBTRACT,
	  MULTIPLY, and DIVIDE with a floating-point destination
	  (COMP-1 or COMP-2) and the ROUNDED option could result in
	  a wrong answer.

Thank for you the very concise example which we were able to use to reproduce
this problem on our systems.

- Don Braffitt
  DEC/VAX COBOL project leader
3217.11See CLT::DEC_COBOL_IFT note 2.58 for a kit with the fixPACKED::BRAFFITTTue Apr 22 1997 11:120