Type punning in C

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Oct 7 11:09:35 AEST 1989


In article <475 at idacrd.UUCP> desj at idacrd.UUCP (David desJardins) writes:
>   Does anyone have any ideas on how one should go about converting an
>integer to the floating-point number with the same bit pattern?

The simple answer is, you shouldn't need to do that!

However, C does provide "union" types that can be used for such purposes.
Load the bit pattern into the integer union member and extract it via the
floating-point member.



More information about the Comp.lang.c mailing list