blob: 31b494fe08a126047bb0b9c748a07be60e13318d (
plain)
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
|
double
unsigned_to_double1 (u)
unsigned u;
{
double d;
d = (int) u; /* convert as from a *signed* integer */
return ((int) u < 0)
? d + 4294967296.0
: d;
}
/* Alternatively */
double
unsigned_to_double2 (u)
unsigned u;
{
double d;
u -= 2147483648; /* complement sign bit */
d = (int) u; /* convert as from a *signed* integer */
return d + 2147483648.0;
}
unsigned
double_to_unsigned (d)
double d;
{
d += 2147483648.0;
return ((int) d) - 2147483648;
}
|