[Top][All Lists]

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

Re: [open-cobol-list] displaying max values in comp-5 field

From: Michael
Subject: Re: [open-cobol-list] displaying max values in comp-5 field
Date: Mon, 27 Jul 2009 12:25:44 -0500
User-agent: Thunderbird (Windows/20090605)

Compatible variables required: In most Cobol compilers, it is the 'MOVE' that will convert (cast), and therefore 'truncate', that's the beauty of the Cobol 'Move' verb.

However, if you don't want the 'MOVE' verb to muck up your good intentions, then don't use move. COMPUTE, DIVIDE, MULTIPLE, ADD, and SUBTRACT will work at the bit level, and for example "S9(4) COMP", you should be able to manipulate all 16 bits.


vince coen wrote:
On Monday 27 July 2009, Sergey Kashyrin wrote:

I think it's not about that
It's about DISPLAY which actually not suppose to display ANY binary or
comp-3/4/5 fields. I don't see any contradictions with formal Cobol.

Oops, I 'assumed' that you had moved it to a numeric display field prior to display, but my argument is still valid against various compilers in that auto truncation can occur and manipulating a s9(4) field after over flow any thing can and no doubt will, happen so it is still verifyable to fix by change to s9(5) as needed.

There again I have programmed in the basis of a specific compilers behaviour as against what the language specs say. It is only over the last few years that I have changed my programming style to match the language specs knowing that the compiler will no doubt change during the life of the app which will be longer than I have anticipated as proven with code written in the 60's and 70's now being converted from MF workbench to run under Open Cobol.


Not going to do any fixes on that, correct me if I wrong


----- Original Message -----
From: "vince coen" <address@hidden>
To: <address@hidden>
Sent: Sunday, July 26, 2009 7:05 AM
Subject: [open-cobol-list] displaying max values in comp-5 field


On Saturday 25 July 2009, Robert Keane wrote:
Hello All,

I've found a problem when displaying the maximum value in a comp-5
field. If an s9(4) comp-5 can hold +32767 or -32768. After initializing
or moving +32767 or -32768 to the s9(4) comp-5 field the display gives
+2767 or -2768, the high order digit is dropped. However if the comp-5
field is moved to a field defined with enough z's the display is ok.
A dropped leading digit does not supprise me.  Moving above 9,999 to a
pic s9 (4) will result in truncation. Solution is to increase picture
size to reflect the maximum value your field will get to in this case pic
s9(5) comp-5.

Or better still use binary-short, its more effective for arithmetic etc
in OC.


open-cobol-list mailing list

reply via email to

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