VAX real number conversion programs
Maj Brian Boyter
bimbo!boyter at uunet.uu.net
Fri Sep 29 10:40:43 AEST 1989
In article <1763 at brazos.Rice.edu>, dinah at 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 at 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 at virginia.acc.virginia.edu ( )
||
Nuke'm 'till they glow ||
...Then shoot'm in the dark ________< >_______
More information about the Comp.sys.sun
mailing list