gnucobol-users
[Top][All Lists]
Advanced

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

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


From: Robert Keane
Subject: [open-cobol-list] displaying max values in comp-5 field
Date: Sat, 25 Jul 2009 18:58:24 -0400
User-agent: Thunderbird 2.0.0.22 (X11/20090608)

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.


Bob Keane

 s9(4) s/b -32768 is -2768
 s9(4) s/b 32767 is                32767
 s9(9) s/b +2147483637 +147483637
 s9(18) s/b +9223372036854775807 +223372036854775807
 s9(2)v99 s/b +25.67 is +25.67
       >>SOURCE FORMAT IS FREE
program-id. "comp5test".
*>_______________________________________________________________________________________
*>
*> Author.       rkeane
*> Date-written. 25 Jul 2009
*> Purpose.      A program to test comp-5 vars
*>_______________________________________________________________________________________
data division.
working-storage section.
01 returnCode                     pic s9(4)    comp-5 value zero.

01 testComp5a                     pic s9(4)    comp-5 value -32768.
01 testComp5b                     pic s9(9)    comp-5 value +2147483637.
01 testComp5c                     pic s9(18)   comp-5 value 
+9223372036854775807.
01 testComp5d                     pic s9(2)v99 comp-5 value +25.67.
01 zMask                          pic zzzzzzzzzzzzzzzzzzzz.

procedure division.
a000-main.
  display ' s9(4) s/b -32768 is ' testcomp5a
  move +32000                     to testcomp5a
  add  +767                       to testcomp5a
  move testcomp5a                 to zMask
  display ' s9(4) s/b 32767 is ' zMask

  display ' s9(9) s/b +2147483637 ' testcomp5b

  display ' s9(18) s/b +9223372036854775807 ' testcomp5c

  move +25.67                     to testComp5d
  display ' s9(2)v99 s/b +25.67 is ' testcomp5d

goback.
*>end program comp5test.


reply via email to

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