[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] DIVIDE: wrong remainder
From: |
Sergey Kashyrin |
Subject: |
Re: [open-cobol-list] DIVIDE: wrong remainder |
Date: |
Wed Mar 8 08:30:02 2006 |
Thanks !
Your fix works perfectly.
And the funny thing is:
G:\skatests\cobol>cobol zrun6.cbl;
MERANT Micro Focus Net Express V3
Version 3.1.11 Copyright (C) 1984-2000 MERANT International Ltd.
URN AXCGG/AA0/00000
* Checking complete with no errors - starting code generation
* Generating zrun6
* Data: 752 Code: 680 Literals: 120
G:\skatests\cobol>cbllink zrun6
Micro Focus Net Express - CBLLINK utility
Version 3.1.11 Copyright (C) 1984-2000 MERANT International Ltd.
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
zrun6.obj
cbllds.obj
Creating library zrun6.lib and object zrun6.exp
G:\skatests\cobol>zrun6
+000000000000000430 REM. -1169026867
G:\skatests\cobol>
Regards,
Sergey
----- Original Message -----
From: "Hans-Martin Rasch" <address@hidden>
To: <address@hidden>
Sent: Wednesday, March 08, 2006 5:55 AM
Subject: [open-cobol-list] DIVIDE: wrong remainder
The following code
05 WK-X1 PIC S9(09) COMP.
05 WK-X2 PIC S9(09) COMP.
05 WK-X3 PIC S9(09) COMP.
05 WK-X4 PIC S9(10) COMP.
.
.
MOVE 4301 TO WK-X1.
MOVE 10 TO WK-X2.
DIVIDE WK-X2 INTO WK-X1
GIVING WK-X4 REMAINDER WK-X3.
DISPLAY WK-X4 " REM. " WK-X3.
gives the output
+00000000000000000430 REM. -0000180599
Reason: In cob_div_quotient() there is a call of cob_decimal_get_field() which
in turn calls cob_decimal_get_binary(). This function uses cob_d2 as a
temporary variable, if the field size is > 4. Thus the previous value of
cob_d2 is destroyed.
This can be fixed by introducing an new variable
"static cob_decimal cob_d5;"
and replacing cob_d2 by cob_d5 in cob_div_quotient()
(not to forget "cob_decimal_init (&cob_d5);"
in cob_init_numeric() ).
Regards
Hans-Martin Rasch
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list