home *** CD-ROM | disk | FTP | other *** search
- From: larryw@milton.u.washington.edu (Larry Weissman)
- Newsgroups: alt.sources
- Subject: [sun-spots] Gould floating point
- Message-ID: <1990May24.185305.7799@math.lsa.umich.edu>
- Date: 24 May 90 18:53:05 GMT
-
- Archive-name: dgfloat/23-May-90
- Original-posting-by: larryw@milton.u.washington.edu (Larry Weissman)
- Original-subject: Gould floating point
- Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
-
- [Reposted from comp.sys.sun.
- Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]
-
- >In response to the message from PRABAL@rcgl1.eng.ohio-state.edu (Prabal Acharyya)
- >in V9-162:
- >> Can anybody explain the binary format used by SUN OS 4.0.3 to represent
- >> floating point numbers. I am trying to convert floating point numbers
- >> from a Gould 32/77 machine to my SUN 4/330.
- >
- >I can share the following from my experience writing just such a
- >translator for IBM-VM/CMS floating point to Sun format (which is standard
- >ieee fmt):
- >...
-
- If the Gould uses IBM 360/370 floating point representation, you can use
- the code below for conversion. This runs on the SPARCstation, not the
- Gould. This code is not specific to SPARCstations, but some machines, like
- DEC's, require byte swapping and exponent range checking.
-
- #include <math.h>
- /*
- * dgfloat: convert dg mv-series (aka IBM 360/370) floating point data
- */
- float dgfloat(r)
- float r;
- {
- double e; /* exponent */
- float f; /* result */
- union u_tag {
- float r;
- long l;
- } u;
-
- u.r = r;
- e = ((u.l & 0x7f000000) >> 24) - 64; /* should check range */
- f = (u.l & 0x00ffffff) / 16777216.0; /* /2^24 */
- f *= pow(16.0,e);
- return(u.l & 0x80000000 ? -f : f );
- }
-
- Larry Weissman Center for Bioengineering, WD-12
- larryw@nsr.bioeng.washington.edu Univ of Washington, Seattle WA 98195
- (206)685-2011
-