NCEPLIBS-g2c
1.7.0
rdieee.c
Go to the documentation of this file.
1
6
#include "
grib2_int.h
"
7
20
void
21
rdieee
(
g2int
*rieee,
float
*a,
g2int
num)
22
{
23
24
g2int
j;
25
g2int
isign,iexp,imant;
26
27
float
sign,temp;
28
static
float
two23,two126;
29
static
g2int
test=0;
30
uint64_t msk1=0x80000000;
// 10000000000000000000000000000000 binary
31
g2int
msk2=0x7F800000;
// 01111111100000000000000000000000 binary
32
g2int
msk3=0x007FFFFF;
// 00000000011111111111111111111111 binary
33
34
if
( test == 0 ) {
35
two23=(float)
int_power
(2.0,-23);
36
two126=(float)
int_power
(2.0,-126);
37
test=1;
38
}
39
40
for
(j=0;j<num;j++) {
41
//
42
// Extract sign bit, exponent, and mantissa
43
//
44
isign=(rieee[j]&msk1)>>31;
45
iexp=(rieee[j]&msk2)>>23;
46
imant=(rieee[j]&msk3);
47
//printf("SAGieee= %ld %ld %ld\n",isign,iexp,imant);
48
49
sign=1.0;
50
if
(isign == 1) sign=-1.0;
51
52
if
( (iexp > 0) && (iexp < 255) ) {
53
temp=(float)
int_power
(2.0,(iexp-127));
54
a[j]=sign*temp*(1.0+(two23*(float)imant));
55
}
56
else
if
( iexp == 0 ) {
57
if
( imant != 0 )
58
a[j]=sign*two126*two23*(float)imant;
59
else
60
a[j]=sign*0.0;
61
62
}
63
else
if
( iexp == 255 )
64
a[j]=sign*(1E+37);
65
66
67
}
68
69
}
rdieee
void rdieee(g2int *rieee, float *a, g2int num)
This subroutine reads a list of real values in 32-bit IEEE floating point format.
Definition:
rdieee.c:21
int_power
double int_power(double x, g2int y)
Function similar to C pow() power function.
Definition:
int_power.c:18
grib2_int.h
Header file with internal function prototypes NCEPLIBS-g2c library.
g2int
int64_t g2int
Long integer type.
Definition:
grib2.h:28
src
rdieee.c
Generated by
1.8.17