[sun-spots] Gould floating point

Larry Weissman larryw at milton.u.washington.edu
Fri May 25 04:53:05 AEST 1990


Archive-name: dgfloat/23-May-90
Original-posting-by: larryw at milton.u.washington.edu (Larry Weissman)
Original-subject: Gould floating point
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)

[Reposted from comp.sys.sun.
Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti).]

>In response to the message from PRABAL at 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 at nsr.bioeng.washington.edu       Univ of Washington, Seattle WA 98195
(206)685-2011



More information about the Alt.sources mailing list