[comp.lang.fortran] "PACKED COMP-3" format

stevej@synopsys.synopsys.com (Steven Jukoff) (07/18/90)

Does anyone know how to define or describe the data format
of the COBOL "PACKED COMP-3" format?  Given the definition,
I need to write a 'C' routine to convert it to an integer:
32 bit 2's complement.

I don't expect to have a problem with the routine given the
correct definition.  This is a "real-world" problem.

Thanks in advance and you may have the code if I get the 
definition.

[Sorry for the Fortran post.  There is no COBOL newsgroup.]

Steven Jukoff,             Phone: (415)962-5407
Synopsys, Inc.             FAX:   (415)965-8637
1098 Alta Ave              DDN:   stevej@synopsys.com
Mountain View, CA 94043    UUCP:  ..!uunet!fernwood!synopsys!stevej

khb@chiba.Eng.Sun.COM (Keith Bierman - SPD Advanced Languages) (07/18/90)

In article <557@synopsys.COM> stevej@synopsys.synopsys.com (Steven Jukoff) writes:

...

   [Sorry for the Fortran post.  There is no COBOL newsgroup.]

There is an alt.cobol.

I passed this off to a COBOL-fiend and this was his response:


To: khb@chiba
Subject: Re:  up your alley ?

> Does anyone know how to define or describe the data format
> of the COBOL "PACKED COMP-3" format?

In Micro Focus COBOL it simply means BCD (2 digits to a packed byte)
Trivial to convert to integer.    The mileage may vary with other
vendors.   The "USAGE IS COMP-x" clause often means floating point,
which scares the panties right off most good honest COBOL programmers.

Please forward this elucidation to comp.lang.fortran next time you're passing.

Regards,

...

So COBOL programmers fear honest floating point.... ;>

--
Keith H. Bierman    |*My thoughts are my own. !! kbierman@Eng.Sun.COM
It's Not My Fault   | MTS --Only my work belongs to Sun* khb@chiba.Eng.Sun.COM
I Voted for Bill &  | Advanced Languages/Floating Point Group (415 336 2648)   
Opus<khb@eng.sun.com> "When the going gets Weird .. the Weird turn PRO"

mikel@pyramid.pyramid.com (Mike Lipsie) (07/18/90)

In article <KHB.90Jul17174936@chiba.Eng.Sun.COM> khb@chiba.Eng.Sun.COM (Keith Bierman - SPD Advanced Languages) writes:
>
>In article <557@synopsys.COM> stevej@synopsys.synopsys.com (Steven Jukoff) writes:
>> Does anyone know how to define or describe the data format
>> of the COBOL "PACKED COMP-3" format?
>
>In Micro Focus COBOL it simply means BCD (2 digits to a packed byte)
>Trivial to convert to integer.    The mileage may vary with other
>vendors.   The "USAGE IS COMP-x" clause often means floating point,
>which scares the panties right off most good honest COBOL programmers.

Now to embarass myself in public by admitting I [used to] know
COBOL.  :-)

COMP is short for COMPUTATIONAL.  COMPUTATIONAL[-x] is used for
"performance" and indicates that you want to use one of the
machines internal (hardware) representations.

COMPUTATIONAL is integer (and 16, 32, or 64 bit was chosen on the
	basis of the number of digits required.)

COMPUTATIONAL-1 and -2 are single and double precision floating
	point (respectively.)

COMPUTATIONAL-3 is packed decimal.  It is trivial to convert to
	integer if you have an integer form with enough digits.
	Also, since there is a decimal point, you must remember
	where it is and scale accordingly.

	The internal form of packed decimal was two decimal
	digits per byte _except_ the next to last nibble
	which was the sign and usually C, D, E, or F depending
	on plus or minus and read vs. computed.

I got all this from the IBM 7044 COBOL but it was the same on
the 360 series (at least for the F-level and above compilers.)

Now that you have gotten far more COBOL than you ever wanted, we 
return you to your normal requests for a Fortran to C converter.  :-)

-----------
Mike Lipsie                                         mikel@pyramid.com
Pyramid Technology Corp, Mountain View, CA            +1 415 335-8657
-- 
-----------
Mike Lipsie                                         mikel@pyramid.com
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200 ext. 4980

worley@compass.COM (Dale Worley) (07/23/90)

In article <120309@pyramid.pyramid.com> mikel@pyramid.pyramid.com (Mike Lipsie) writes:
   COMPUTATIONAL is integer ...
   COMPUTATIONAL-1 and -2 are single and double precision floating ...
   COMPUTATIONAL-3 is packed decimal...

But do beware that this is just the way IBM does it.  Other vendors
are free to use different formats for COMP-n items.

Dale Worley		Compass, Inc.			worley@compass.com
--
That's so deep, I'm getting the bends.... If you want me, I'll
be in the decompression chamber.