[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cobol

Title:VAX/DEC COBOL
Notice:Kit,doc,performance talk info-->DIR/KEY=KIT or DOC or PERF_TALK
Moderator:PACKED::BRAFFITT
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3250
Total number of notes:13077

3212.0. "Question on COMP-1, 2 and /float=D, G" by DEKVC::JOONGSUNJUN () Mon Mar 10 1997 08:47

    Hi,

    My customer wants to know how many bits are assigned for exponent and 
    fractional part of comp-1.  Also, if he use /float=d_float or 
    /float=g_float during compiling cobol source, please inform me about
    each case's bits assignment for comp-2.

    If this questions is not suitable for this conference, please inform me
    correct one.  Thank you.

    Best Regards,
    Joong-Sun Jun.

T.RTitleUserPersonal
Name
DateLines
3212.1Alpha floating point detailsPACKED::BRAFFITTMon Mar 10 1997 09:4837
>    My customer wants to know how many bits are assigned for exponent and 
>    fractional part of comp-1.  Also, if he use /float=d_float or 
>    /float=g_float during compiling cobol source, please inform me about
>    each case's bits assignment for comp-2.

    These details are combined from material in
    
    	Alpha Architecture Handbook 1992 pp. 2-3 - 2-9
    	DEC COBOL Reference Manual	 pp. 5.141 - 5.142
    	DEC COBOL User Manual		 Compatibility Appendix
    
    	Alpha			Exponent Fraction Approximate	 DEC COBOL
    	Datatype		Bits	 Bits	  Decimal Digits Qualifier
    	--------------------------------------------------------------------
    	COMP-1	F_floating	 8	 24	   7		 /FLOAT=D or G
    	COMP-2	G_floating	11	 53	  15		 /FLOAT=G
    	COMP-2	D_floating	11	 53	  16		 /FLOAT=D
    	COMP-1	S_floating	 8	 23	   *		 /FLOAT=IEEE
    	COMP-2	T_floating	11	 52	   *		 /FLOAT=IEEE
    
        * Not specified in Alpha Architecture Handbook
    
    	Note that with F_, D_, and G_, the redundant most significant	
    	fraction bit is not represented.
    
    	"D_floating is not a fully supported data type; no D_floating
    	 arithmetic operations are provided in the architecture ...
    	 D_floating 'format compatibility' in which binary files of
     	 D_floating numbers may be processed, but without the last
    	 3 bits of fraction precision, can be obtained by conversions
    	 to G_floating, G arithemetic operations, then conversions
    	 back to D_floating."
    
    	Note that /FLOAT=D is the default with DEC COBOL on OpenVMS Alpha
        for partial (but not 100%) compatibility with VAX COBOL.  /FLOAT=D	and
        /FLOAT=G are not available on other supported DEC COBOL	platforms
        where /FLOAT=IEEE is the DEC COBOL default.
3212.2F & S are similar; G & T are similarWIBBIN::NOYCEPulling weeds, pickin' stonesMon Mar 10 1997 12:4717
Don, which of those references suggests that S has fewer fraction
bits than F, and that T has fewer fraction bits than G?  In fact,
the formats are very similar within these pairs.

F and S both have an 8-bit exponent, and both use a 24-bit fraction
with the leading bit suppressed, to occupy 23 bits in storage.  That
leaves 1 bit for the sign (8+23+1=32).  These formats provide about
7 decimal digits of precision.  They differ in how the bits are
ordered, how the exponent is represented, and the exact endpoints of
the range of representable numbers.

G and T both have an 11-bit exponent, and both use a 53-bit fraction
with the leading bit suppressed, to occupy 52 bits in storage.  That
leaves 1 bit for the sign (11+52+1=64).  These formats provide about
15 decimal digits of precision.  They differ in how the bits are
ordered, how the exponent is represented, and the exact endpoints of
the range of representable numbers.
3212.3Quotes from 1992 Alpha Architecture HandbookPACKED::BRAFFITTMon Mar 10 1997 14:1513
>Don, which of those references suggests that S has fewer fraction
>bits than F, and that T has fewer fraction bits than G?  In fact,
>the formats are very similar within these pairs.

    The Alpha Architecture Handbook 1992:
    
      p. 2-4 D-floating - "normalized 24-bit fraction"
      p. 2-5 G-floating - "normalized 53-bit fraction"
      p. 2-8 S-floating - "23-bit fraction"
      p. 2-9 T-floating - "52-bit fraction"
    
    and it explains the details about the redundant most significant
    fraction bit not being represented for D/G.
3212.4More QuestionsDEKVC::JOONGSUNJUNTue Mar 11 1997 07:5840
    Hi,

    Thank you for your help.  Please see some more questions and advise me.
    
>>      Alpha			Exponent Fraction Approximate	 DEC COBOL
>>    	Datatype		Bits	 Bits	  Decimal Digits Qualifier
>>    	--------------------------------------------------------------------
>>    	COMP-1	F_floating	 8	 24	   7		 /FLOAT=D or G
>>    	COMP-2	G_floating	11	 53	  15		 /FLOAT=G
>>    	COMP-2	D_floating	11	 53	  16		 /FLOAT=D

    Q1.  Dose "Approximae Decimal Digits" mean that it is recommanded
         for my customer only to use 7, 15, or 16 bytes for numerice data ?

	 For instance,

		77  float_num		comp-2.		!  (/float=D)
		77  num_string		pic s9(x)v9(y).

		    move float_num to num_string.

	 Dose my customer need to define total number of bytes for x and y
	 as only 16 for precision of numeric data ?  That is, s9(10)v9(6),
         or s9(3)v9(13) comp, etc only provides precise numeric data ?

>>    	Note that with F_, D_, and G_, the redundant most significant	
>>    	fraction bit is not represented.

    Q2.  Does this imply, for example, 24 fraction bits include 1 sign bit ?

    
>>    	"D_floating is not a fully supported data type; no D_floating
>>    	 arithmetic operations are provided in the architecture ...

    Q3.  Does this mean that G float is better than D float for my customer
	 to increase data precision and performance on DEC COBOL, Alpha/
	 OpenVMS ?

    Best Regards,
    Joong-Sun Jun.
3212.5WIBBIN::NOYCEPulling weeds, pickin' stonesTue Mar 11 1997 12:4731
    Q1.  Dose "Approximae Decimal Digits" mean that it is recommanded
         for my customer only to use 7, 15, or 16 bytes for numerice data ?

This means that a COMP-1 can represent numbers to approximately 1 part in 10,000,000.
Nothing should go wrong if you convert COMP-1 to, say,  PIC 9(18), but digits after
the most significant 6 or 7 may not have the values you expect.  Similarly for COMP-2
and 15 or 16 digits.

    Q2.  Does this imply, for example, 24 fraction bits include 1 sign bit ?

The storage for F_float and S_float contains
	1 sign bit
	8 exponent bits
	23 fraction bits, representing all but the leading '1' of a
	   24-bit fraction.  (The leading bit is always '1' because
	   the fraction is normalized, so it doesn't need to be
	   stored.  The only exception is when the exponent field
	   is all zero.)

    Q3.  Does this mean that G float is better than D float for my customer
	 to increase data precision and performance on DEC COBOL, Alpha/
	 OpenVMS ?

Performance for G_float could be slightly better, since you avoid the cost
of converting between D and G when loading and storing.  The precision for
the two formats is the same, since D arithmetic is all done in G format.
G_float provides a greater range (about 1e-300..1e300) than D_float (about
1e-38..1e38).  Pick the format that's compatible with the files you need
to process, or with software you need to call (such as databases).  If that
doesn't decide it, I would be tempted to use G, even though the default is
D for compatibility with VAX COBOL.