19 union {
unsigned u;
unsigned char c[4]; } temp;
22 ctemp = temp.c[0]; temp.c[0] = temp.c[3]; temp.c[3] = ctemp;
23 ctemp = temp.c[1]; temp.c[1] = temp.c[2]; temp.c[2] = ctemp;
28 #define swap_int(a) ( ((a) << 24) | \
29 (((a) << 8) & 0x00ff0000) | \
30 (((a) >> 8) & 0x0000ff00) | \
31 ((unsigned long)(a) >>24) )
33 #define swap_short(a) ( ((a & 0xff) << 8) | ((unsigned short)(a) >> 8) )
39 #if defined(WORDS_BIGENDIAN)
48 #if defined(WORDS_BIGENDIAN)
57 #if defined(WORDS_BIGENDIAN)
66 #if defined(WORDS_BIGENDIAN)
75 #if defined(WORDS_BIGENDIAN)
87 #if defined(WORDS_BIGENDIAN)
99 #if defined(WORDS_BIGENDIAN)
101 unsigned *uia = (
unsigned*)ia;
112 #if defined(WORDS_BIGENDIAN)
114 unsigned *uia = (
unsigned*)ia;
136 # define VMS_FLOAT_NATIVE CVT$K_IEEE_S
137 # define VMS_DOUBLE_NATIVE CVT$K_IEEE_T
140 # define VMS_FLOAT_NATIVE CVT$K_VAX_F
141 # define VMS_DOUBLE_NATIVE CVT$K_VAX_D
144 # define VMS_FLOAT_NATIVE CVT$K_VAX_F
145 # define VMS_DOUBLE_NATIVE CVT$K_VAX_G
147 # error Cannot determine VMS floating point format
155 unsigned int sign : 1;
156 unsigned int exp : 8;
163 unsigned int sign : 1;
164 unsigned int exp : 8;
187 #define VAX_SNG_BIAS 0x81
188 #define IEEE_SNG_BIAS 0x7f
194 {{ 0x7f, 0xff, 0x0, 0xffff },
196 {{ 0x0, 0x0, 0x0, 0x0 },
200 #define mmax sgl_limits[0]
201 #define mmin sgl_limits[1]
208 unsigned int sign : 1;
209 unsigned int exp : 11;
218 unsigned int sign : 1;
219 unsigned int exp : 8;
246 #define VAX_DBL_BIAS 0x81
247 #define IEEE_DBL_BIAS 0x3ff
248 #define MASK(nbits) ((1 << nbits) - 1)
254 {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff },
255 { 0x0, 0x7ff, 0x0, 0x0 }},
256 {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
257 { 0x0, 0x0, 0x0, 0x0 }}
265 unsigned char c_tmp, *c_p = (
unsigned char*)p;
275 # define maybe_flip_bytes(__p,__n)
314 *fp = *((
float*)&is);
327 if(is.mantissa ==
mmin.ieee.mantissa)
331 unsigned tmp = is.mantissa >> 20 ;
334 }
else if (tmp >= 2) {
340 tmp = is.mantissa - (1 << (20 + vs.
exp )) ;
357 *fp = *((
float*)&vs);
366 #include <cvt$routines>
374 if ( cvt$ftof(val+i, CVT$K_VAX_F, val+i, CVT$K_VAX_F, CVT$M_REPORT_ALL) != CVT$K_NORMAL )
379 #elif defined(IEEEFP)
388 #error Unknown floating point format
399 #elif defined(IEEEFP)
408 #error Unknown floating point format
423 if ( cvt$ftof(val+i, CVT$K_IEEE_S, val+i, VMS_FLOAT_NATIVE, 0) != CVT$K_NORMAL )
430 #error Unknown floating point format
441 #include <cvt$routines>
446 if ( cvt$ftof(val+i, CVT$K_IEEE_T, val+i, VMS_DOUBLE_NATIVE, CVT$M_REPORT_ALL) != CVT$K_NORMAL )
453 #error Unknown floating point format
464 #include <cvt$routines>
469 if ( cvt$ftof(val+i, VMS_FLOAT_NATIVE, val+i, CVT$K_IEEE_S, CVT$M_REPORT_ALL) != CVT$K_NORMAL )
476 #error Unknown floating point format
490 if ( cvt$ftof(val+i, VMS_DOUBLE_NATIVE, val+i, CVT$K_IEEE_T, CVT$M_REPORT_ALL) != CVT$K_NORMAL )
497 #error Unknown floating point format
503 static unsigned char flip_bits(
unsigned char cc)
506 static unsigned char ct[256];
510 for(_i=0; _i<256; _i++)
513 for(_j=0; _j<8; _j++)
515 if (_i & (1<<_j)) { ct[_i] |= (128 >> _j); }
unsigned short vax_to_local_short(const unsigned short *s)
void ieee_float_to_local(float *val, const int *n, int *errcode)
void vax_to_local_shorts(unsigned short *sa, const int *n)
void local_to_ieee_float(float *val, const int *n, int *errcode)
unsigned local_to_vax_int(const fort_int *i)
void local_to_vaxf(float *val, const int *n, int *errcode)
void local_to_vax_ints(fort_int *ia, const fort_int *n)
void vax_to_local_ints(fort_int *ia, const fort_int *n)
static int vax_to_ieee_float(float *fp)
unsigned vax_to_local_int(const fort_int *i)
static struct sgl_limits_struct sgl_limits[2]
#define maybe_flip_bytes(__p, __n)
void local_to_ieee_double(double *val, const int *n, int *errcode)
static int ieee_to_vax_float(float *fp)
void ieee_double_to_local(double *val, const int *n, int *errcode)
void local_to_vax_shorts(unsigned short *sa, const int *n)
void vaxf_to_local(float *val, const int *n, int *errcode)
unsigned short local_to_vax_short(const unsigned short *s)