#include /* VAX float representation: ** ** bit: 0 31 ** +--------------+-+------+------+ ** | FRACTION |S| EXP | FRAC | ** +--------------+-+------+------+ ** ** The exponent is stored in binary 128 excess notation. ** The fraction is a 24-bit normalized fraction with the most significant bit ** not stored. If the exponent is not 0, this bit is assumed to be 1. A ** number with sign 0 and exponent 0 is assumed to be 0. in value. */ void vaxfloat(int *val,float *rval,int num) { /* val is the first address of a block of integers containing the ** representations of the VAX floats ** rval is the first address of a block of floats in native format created from ** the VAX representations ** num is the number of VAX representations to convert to native format */ int n,sign,exp,fr[2]; for (n=0; n < num; n++) { /* unpack sign, exponent, and fraction */ gbyte32(&val[n],&sign,16,1); gbyte32(&val[n],&exp,17,8); if (exp == 0) rval[n]=0.; else { exp-=128; gbyte32(&val[n],&fr[0],0,16); gbyte32(&val[n],&fr[1],25,7); /* reconstruct fraction */ fr[0]+=((fr[1] << 16) | 0x800000); rval[n]=fr[0]*pow(2.,(float)(exp-24)); if (sign == 1) rval[n]=-rval[n]; } } }