home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!elroy.jpl.nasa.gov!ames!sun-barr!news2me.ebay.sun.com!jethro.Corp.Sun.COM!exodus.Eng.Sun.COM!positive.Eng.Sun.COM!linden
- From: linden@positive.Eng.Sun.COM (Peter van der Linden)
- Newsgroups: comp.lang.c
- Subject: Re: Convert COBOL COMP-3 to double?
- Date: 27 Aug 1992 16:46:45 GMT
- Organization: Sun Microsystems, Mt. View, Ca.
- Lines: 19
- Message-ID: <l9q1nlINN8f7@exodus.Eng.Sun.COM>
- References: <1992Aug26.151021.4445@afs.com>
- NNTP-Posting-Host: positive
-
- From: jack@afs.com (Jack Brasch)
- > Could someone point me in the right direction or mail me a routine to
- > convert COBOL COMP-3 types to a double.
-
- The COMP-3 format is implementation defined, but in most implementations
- it is some form of binary-coded decimal (BCD) in which 2 digits are
- stored in each byte (1 per nibble). There's some jiggery-pokery for the
- sign.
-
- I would suggest converting it to an int or long first, then floating it,
- then adjusting for the implied decimal point. COBOL can hold up to 18
- digits of precision in its fixed-point formats, so you may lose accuracy
- when you hold the number as a double.
-
- Peter
- --
- linden@eng.sun.com|| P. van der Linden and his uncustomary theories.
- Go Giants!! Don't || When solving a "panic" you must first ask yourself what you
- stop at Florida...|| were doing that could possibly frighten an operating system
-