HP3000-L Archives

September 2006, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Denys Beauchemin <[log in to unmask]>
Reply To:
Date:
Fri, 29 Sep 2006 15:31:05 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (97 lines)
COBOL doesn't give a rodent's behind about whatever data item type is used
in IMAGE, and IMAGE doesn't care what you stick into these items either.
The only reason there are so many data types in IMAGE is to help Query and
similar self-adjusting programs in discovering how to interpret the pattern
of bits stored at said location.  (About the only place IMAGE cares about
the item type is for key items in master datasets, hashed vs non-hashed
keys.)

R4 and E4 are 64 bits wide and R2 and E2 are 32 bits wide.  You could have
use J4 and J2 or U8 and X4 for all that COBOL or IMAGE care.

The big problem that you have is that 32 bit real numbers are precise up to
6.7 positions and 64 bit numbers are precise up to 13.4 positions.

You can see that in action where your 64 bit values are much more precise
than your 32 bit values.

When I write applications in BASIC eons ago, I designed SPL routines that
would twiddle bits to round out numbers to two decimal places.  It involved
adding .005 and using INEXT and EXTIN and other things.

Denys

-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On Behalf
Of Brian Donaldson
Sent: Friday, September 29, 2006 2:47 PM
To: [log in to unmask]
Subject: [HP3000-L] Cobol Real numbers

Michael:
 
 
According to the Image/3000 manual (blue book) these "R" and "E" 
data  types are not valid in Cobol.
 
That may be what is giving you problems in your Cobol program....
 
Valid data types in Cobol are "X", "U", "J", "I" and "P"....
 
Brian Donaldson.
 
 
<<snip>>
 
I've been trying to make use of some very old data, and again, all  I
have is COBOL. I hope some could help me out here.

COBOL  TEST
Using a test database, with one dataset that has four fields,  defined
as R4, R2, E4, E2, I entered the same exact value ( -987654321.05 )  into
each field using Query.

Can anyone point me in the right  direction as to why I am not getting
the -987654321.05 returned.
Using  COBOL 
COBOL X8 Image R4 

CALL INTRINSIC  "HPFPCONVERT" USING
X8R4V18-Realr4, X8-IEEE, 2, 4, STATUS-WORD,  EXCEPTIONS.
CALL INTRINSIC "HPINEXT"  USING
X8-IEEE, -2, 42, 18,  -3, 0, String-Amount, ERR

String-Amount:  [-987654321.04999989                        ]

Does NOT get better with the R2 item.

COBOL X4 Image R2  

CALL INTRINSIC "HPFPCONVERT"  USING
X4R2V18-REALR2,  X4-IEEE, 1, 3, STATUS-WORD, EXCEPTIONS
CALL  INTRINSIC "HPINEXT" USING
X4-IEEE,  1, 42, 18, -3, 0, String-Amount, ERR

String-Amount:  [-98765.0625                                ]


COBOL X8 Image E4 :  [-987654321.04999989                        ]


COBOL X4 Image E2 :  [-98765.0546875                             ]


The same program works perfect with small positive amounts,  like
456.50. The R4, R2, E4, and E2 all are returned as  456.5.






* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2