Page 1 of 1

How to display sign only in case of negative number in cobol

PostPosted: Fri Apr 08, 2016 6:24 pm
by gauthamnagpur18
Hi,

I need help on signed integer concept.

I have defined output variable as PIC S9(07)V99 SIGN LEADING SEPARATE.

By this way, we are getting sign before the number .

I got requirement to display sign only in the case of negative. In case of positive, number should not come with positive sign.

Thanks in advance.

Re: How to display sign only in case of negative number in c

PostPosted: Fri Apr 08, 2016 6:45 pm
by BillyBoyo
You use a numeric-edited PICture, and specify at least on "-" (minus sign) in an appropriate place. The "-" position will appear as that character for a negative value, but space will appear instead if positive.

If you want "+" to appear instead of space, and still have the "-" for negative values, you'd use a "+" (plus sign) in the PICture instead.

Re: How to display sign only in case of negative number in c

PostPosted: Fri Apr 08, 2016 7:17 pm
by Terry Heinze
In the COBOL Language Reference Manual, see DATA DIVISION, PICTURE Clause, Fixed insertion editing.

Re: How to display sign only in case of negative number in c

PostPosted: Sat Apr 09, 2016 10:44 pm
by gauthamnagpur18
Hi,

Thanks all for your help.It worked out.

I have declared variable as PIC -9(07)V99.

:D :D :D