HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
17 user(s) are online (6 user(s) are browsing Forum)

Members: 0
Guests: 17

more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     different (wrong) results on comp-3 depending on fnotrunc
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
SigMilWas
Posted on: 2012/6/28 16:46
Just popping in
Joined: 2011/4/16
From: Germany
Posts: 6
different (wrong) results on comp-3 depending on fnotrunc
Hi guys,
I'am using OC 1.1 on suselinux.

Have a look on this simple program named cobnum.cbl:

IDENTIFICATION DIVISION.
        PROGRAM-ID. cobnum.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01    FLD1     PIC S9(9) COMP-3.
        01    FLD2     PIC S9(9) COMP-3.
        01    FLD3     PIC S9(9) COMP-3.
        PROCEDURE DIVISION.
        000-Main.
            DISPLAY 'Testprogramm'.
            DISPLAY 'Test 1'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1.
            DISPLAY 'Erg FLD1-FLD2 =' FLD1.

            DISPLAY 'Test 2'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1 GIVING FLD3.
            DISPLAY 'Erg FLD1-FLD2 =' FLD3.

            DISPLAY 'Test 3'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1 GIVING FLD1.
            DISPLAY 'Erg FLD1-FLD2 =' FLD1.
          STOP RUN.


Compile this programm with cobc cobnum.cbl.
Run this program with cobcrun cobnum and you will see (all is okay):

Testprogramm
Test 1
Inhalt FLD1   =+000734683
Inhalt FLD2   =+000734684
Erg FLD1-FLD2 =-000000001
Test 2
Inhalt FLD1   =+000734683
Inhalt FLD2   =+000734684
Erg FLD1-FLD2 =-000000001
Test 3
Inhalt FLD1   =+000734683
Inhalt FLD2   =+000734684
Erg FLD1-FLD2 =-000000001


Now compile this programm with cobc -fnotrunc cobnum.cbl.
Run this program with cobcrun cobnum and you will see (the first result is quite wrong) :

Testprogramm
Test 1
Inhalt FLD1   =000734683+
Inhalt FLD2   =000734684+
Erg FLD1-FLD2 =999999999- 
Test 2
Inhalt FLD1   =000734683+
Inhalt FLD2   =000734684+
Erg FLD1-FLD2 =000000001-
Test 3
Inhalt FLD1   =000734683+
Inhalt FLD2   =000734684+
Erg FLD1-FLD2 =000000001-


Why does the fnotrunc-option weight the computation of com-3 fields?? This seems to be a serious bug.

With kind regards
Michael



btiffin
Posted on: 2012/6/29 3:22
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 1196
Re: different (wrong) results on comp-3 depending on fnotrunc
Micheal.

I'm not going to pretend to be that guy, but Sergey has a good eye to find numeric inaccuracies and the skill to fix them.

Watch the SourceForge SVN tree. Sergey has already posted some updates, libcob/numeric.c was one of the files patched so far. Not for this issue though.

But do keep an eye of the forge at http://sourceforge.net/projects/open-cobol/ and http://open-cobol.svn.sourceforge.net/viewvc/open-cobol/

Cheers,
Brian
human
Posted on: 2012/6/29 14:41
Home away from home
Joined: 2007/5/15
From: GERMANY
Posts: 1416
Re: different (wrong) results on comp-3 depending on fnotrunc
Hi Brian,

can you please add these two samples to the test suite (it's better to have a failed test in trunk than a bug we forget to fix - or to add a similar bug later on). If it's possible I'd like you to add a test for every bugfix that is checked in.
Pleeeeaaase.

Simon 'human' Sobisch
ska
Posted on: 2012/7/12 12:22
Just can't stay away
Joined: 2008/3/17
From: NYC
Posts: 145
Re: different (wrong) results on comp-3 depending on fnotrunc
numeric.c with corresponding fix commited to SVN.


----------------
Regards,
Sergey

SigMilWas
Posted on: 2012/9/10 11:49
Just popping in
Joined: 2011/4/16
From: Germany
Posts: 6
Re: different (wrong) results on comp-3 depending on fnotrunc
Hi Sergey,

we checked out the newest version today (09/10/2012), but the bug is still present.
The module numeric.c was recently changed in september.

Michael
ska
Posted on: 2012/9/12 20:47
Just can't stay away
Joined: 2008/3/17
From: NYC
Posts: 145
Re: different (wrong) results on comp-3 depending on fnotrunc
Updated to the latest from SVN today - I don't see this error. Everything is correct.
And, BTW, I added one thing to your test. If you still have this bug, you will see funny result.
       IDENTIFICATION DIVISION.
       PROGRAM-ID. cobnum.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01    FLD1     PIC S9(9) COMP-3.
       01    FLD2     PIC S9(9) COMP-3.
       01    FLD3     PIC S9(9) COMP-3.
       01    FLD4     PIC S9(7)V99 COMP-3.
       PROCEDURE DIVISION.
       000-Main.
            DISPLAY 'Testprogramm'.
            DISPLAY 'Test 1'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1.
            DISPLAY 'Erg FLD1-FLD2 =' FLD1.

            DISPLAY 'Test 1-A'.
            MOVE 734683.12   TO FLD4.
            DISPLAY 'Inhalt FLD4   =' FLD4.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT 734684 FROM FLD4.
            DISPLAY 'Erg FLD4-FLD2 =' FLD4.

            DISPLAY 'Test 2'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1 GIVING FLD3.
            DISPLAY 'Erg FLD1-FLD2 =' FLD3.

            DISPLAY 'Test 3'.
            MOVE 734683   TO FLD1.
            DISPLAY 'Inhalt FLD1   =' FLD1.
            MOVE 734684   TO FLD2.
            DISPLAY 'Inhalt FLD2   =' FLD2.
            SUBTRACT FLD2 FROM FLD1 GIVING FLD1.
            DISPLAY 'Erg FLD1-FLD2 =' FLD1.
            STOP RUN.


----------------
Regards,
Sergey

Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net