8sa1-gcc/gcc/testsuite/gcc.c-torture/unsorted/udconvert.c
Jeff Law 921e5a0eb4 Initial revision
From-SVN: r14840
1997-08-19 01:34:40 -06:00

31 lines
502 B
C

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;
}