How to test for +/- INFINITY, etc. in C with IEEE

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Dec 16 10:47:08 AEST 1985


>    short pi[4] = {0x4008,0x1234,etc,etc};
>    double x, y;
>    x = y * *(double *)pi

Beware!  The alignment applied to (short) data may not be
sufficiently stringent for (double) data, so the result of
the (double *) typecast (assuming the compiler allows it)
may not be suitable for the address of an operand for a
floating-point instruction.  We have machines like that..

You can overcome this problem by proper use of a union.



More information about the Comp.lang.c mailing list