Max integer in an 8 byte COMP field?



Hello,

I can't figure this out.
Am trying to find the largest integer that will fit inside a 'comp'
field of 8 bytes (64 bits).
Below is the compiler output followed by execution results.
I tried with both signed and unsigned COMP fields.

I can understand why exponents of 64 and 65 go to zero (I think) but:

1. why at 62 does the displayed result have 19 digits (when my Cobol
manuals tell me 18 is the maximum).
2. same for 63, but additionally, why has it gone negative.
3. I still don't know what the largest integer can be.

Any ideas please, thanks.

Graham Hobbs

...............................................

Compiler (VisualAge Cobol V2.2) output:

000091 05 RES1 PIC 9(18) COMP. 8(0000221)
000092 05 RES2 PIC S9(18) COMP. 8(0000229)


000115 DISPLAY '--------------------------------'
000116 COMPUTE RES1 = 2 ** 62 DISPLAY ' RES1=' RES1
000117 COMPUTE RES1 = 2 ** 63 DISPLAY ' RES1=' RES1
000118 COMPUTE RES1 = 2 ** 64 DISPLAY ' RES1=' RES1
000119 COMPUTE RES1 = 2 ** 65 DISPLAY ' RES1=' RES1
000120 DISPLAY '--------------------------------'
000121 COMPUTE RES2 = 2 ** 62 DISPLAY ' RES2=' RES2
000122 COMPUTE RES2 = 2 ** 63 DISPLAY ' RES2=' RES2
000123 COMPUTE RES2 = 2 ** 64 DISPLAY ' RES2=' RES2
000124 COMPUTE RES2 = 2 ** 65 DISPLAY ' RES2=' RES2
000125 DISPLAY '--------------------------------'

Results:
-------------------------------
RES1=4611686018427387904
RES1=-9223372036854775808
RES1=0000000000000000000
RES1=0000000000000000000
-------------------------------
RES2=4611686018427387904
RES2=-9223372036854775808
RES2=0000000000000000000
RES2=0000000000000000000
-------------------------------
Cheers

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: Specialized MTB Shoes
    ... > Anyone have an opinion on the '05 Specialized Carbon Comp or Comp ... > MTB shoes -- apart from fit issues. ... > MTB shoe and these seem to fit well and be in my price range. ...
    (rec.bicycles.tech)
  • Re: Max integer in an 8 byte COMP field?
    ... Graham Hobbs wrote: ... Am trying to find the largest integer that will fit inside a 'comp' ... I tried with both signed and unsigned COMP fields. ... Whether you can display it is another question. ...
    (comp.lang.cobol)
  • Re: Cobol convert program Job Request
    ... Howard Brazee wrote: ... Micro Focus S9COMP is two bytes binary ... How do you fit a sign and four digits into two bytes? ...
    (comp.lang.cobol)
  • Re: Cobol convert program Job Request
    ... Micro Focus S9COMP is two bytes binary ... How do you fit a sign and four digits into two bytes? ...
    (comp.lang.cobol)