File: vmsieee.c

package info (click to toggle)
cfitsio 3.470-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 14,484 kB
  • sloc: ansic: 106,145; yacc: 4,883; sh: 3,259; fortran: 2,613; lex: 504; makefile: 162
file content (130 lines) | stat: -rw-r--r-- 3,782 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <cvtdef.h>
#include <cvtmsg.h>

unsigned long CVT$CONVERT_FLOAT();

/* IEEVPAKR -- Pack a native floating point vector into an IEEE one.
*/
void ieevpr (unsigned int *native, unsigned int *ieee, int *nelem)
{
        unsigned long status;
        unsigned long options;
        unsigned int *unanval;
        int nanval = -1;
        int     i,n;

        unanval = (unsigned int *) &nanval;
        options = CVT$M_BIG_ENDIAN;
        
        n = *nelem;
        status = CVT$_NORMAL;

        for (i = 0; i < n ; i++) {

            status = CVT$CONVERT_FLOAT (&native[i], CVT$K_VAX_F,
                                        &ieee[i], CVT$K_IEEE_S, 
                                        options);
           if (status != CVT$_NORMAL) {
                 ieee[i] = *unanval;
           }
        }       

}
/* IEEVPAKD -- Pack a native double floating point vector into an IEEE one.
*/
void ieevpd (unsigned long *native, unsigned long *ieee, int *nelem)
{
        unsigned long status;
        unsigned long options;
        unsigned long *unanval;
        long nanval = -1;
        int     i,n;

        unanval = (unsigned long *) &nanval;
        options = CVT$M_BIG_ENDIAN;
        
        n = *nelem * 2;
        status = CVT$_NORMAL;

        for (i = 0; i < n ; i=i+2) {

            status = CVT$CONVERT_FLOAT (&native[i], CVT$K_VAX_D,
                                        &ieee[i], CVT$K_IEEE_T, 
                                        options);
           if (status != CVT$_NORMAL) {
                 ieee[i]   = *unanval;
                 ieee[i+1] = *unanval;
           }
        }       

}
/* IEEVUPKR -- Unpack an ieee vector into native single floating point vector.
*/
void ieevur (unsigned int *ieee, unsigned int *native, int *nelem)
{
        unsigned long status;
        unsigned long options;
        unsigned int *unanval;
        int nanval = -1;
        int     j,n;

        unanval = (unsigned int *) &nanval;
        options = CVT$M_ERR_UNDERFLOW+CVT$M_BIG_ENDIAN;
        
        n = *nelem;

        status = CVT$_NORMAL;

        for (j = 0; j < n ; j++) {
           status = CVT$CONVERT_FLOAT (&ieee[j], CVT$K_IEEE_S,
                                        &native[j], CVT$K_VAX_F, 
                                        options);
           if (status != CVT$_NORMAL)
              switch(status) {
              case CVT$_INVVAL:
              case CVT$_NEGINF:
              case CVT$_OVERFLOW:
              case CVT$_POSINF:
                 native[j]   = *unanval;
                 break;
              default:
                 native[j] = 0;             
              }
        }
}
/* IEEVUPKD -- Unpack an ieee vector into native double floating point vector.
*/
void ieevud (unsigned long *ieee, unsigned long *native, int *nelem)
{
        unsigned long status;
        unsigned long options;
        unsigned long *unanval;
        long nanval = -1;
        int     j,n;

        unanval = (unsigned long *) &nanval;
        options = CVT$M_BIG_ENDIAN + CVT$M_ERR_UNDERFLOW; 
        
        n = *nelem * 2;

        status = CVT$_NORMAL;

        for (j = 0; j < n ; j=j+2) {
           status = CVT$CONVERT_FLOAT (&ieee[j], CVT$K_IEEE_T,
                                        &native[j], CVT$K_VAX_D, 
                                        options);
           if (status != CVT$_NORMAL)
              switch(status) {
              case CVT$_INVVAL:
              case CVT$_NEGINF:
              case CVT$_OVERFLOW:
              case CVT$_POSINF:
                 native[j]   = *unanval;
                 native[j+1] = *unanval;
                 break;
              default:
                 native[j]   = 0;             
                 native[j+1] = 0;             
              }
        }
}