From: dwells (Don Wells) To: dwells Subject: ieee-VAX Date: Mon, 2 Oct 89 10:05:10 EDT Path: hudson!uvaarpa!haven!uflorida!ukma!husc6!rice!sun-spots-request From: bimbo!boyter@uunet.uu.net (Maj Brian Boyter) Newsgroups: comp.sys.sun Subject: Re: VAX real number conversion programs Keywords: Source Message-ID: <1833@brazos.Rice.edu> Date: 29 Sep 89 00:40:43 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 52 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 8, Issue 147, message 3 of 8 In article <1763@brazos.Rice.edu>, dinah@nicolle.bcm.tmc.edu (Dinah Anderson) writes: > Does anyone know where there is a program to convert VAX real*2 and real*4 > data files into a format the Sun can read? Thanks. I got this code orginially from bsabata@cs.utexas.edu.... I have modified it somewhat.... /* routine that converts the vax floating point numbers to RT/IEEE floating point format */ float vfloat(vax) float vax; { union { char bytes[4]; float flt; struct { unsigned int sign:1; unsigned int exp:8; unsigned int mant:23; } f; } ieee; union { float flt; char bytes[4]; } vaxx; /* swap bytes */ vaxx.flt = vax; ieee.bytes[0] = vaxx.bytes[1]; ieee.bytes[1] = vaxx.bytes[0]; ieee.bytes[2] = vaxx.bytes[3]; ieee.bytes[3] = vaxx.bytes[2]; /* adjust exponent */ if( ieee.f.exp < 2) ieee.flt = 0.0; /* underflows */ else ieee.f.exp -= 2; return(ieee.flt); } Maj. Brian A Boyter US Army Foreign Science & Technology Center Charlottesville, Va 22901 __ off: (804)980-7362 ( ) home: 973-9440 { } boyter%bimbo.uucp@virginia.acc.virginia.edu ( ) || Nuke'm 'till they glow || ...Then shoot'm in the dark ________< >_______