Path: utzoo!utgpu!watmath!maytag!aries5!lhf From: lhf@aries5.uucp (Luiz H de Figueiredo) Newsgroups: comp.lang.c Subject: Re: Type punning in C Message-ID: <605@maytag.waterloo.edu> Date: 10 Oct 89 15:06:14 GMT References: <475@idacrd.UUCP> <11242@smoke.BRL.MIL> Sender: daemon@maytag.waterloo.edu Reply-To: lhf@aries5.UUCP (Luiz H de Figueiredo) Organization: Computer Systems Group, University of Waterloo Lines: 21 In article <11242@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: > >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. Provided both members have the same size! Otherwise, try union { float f; unsigned char b[sizeof(float)]; }; ------------------------------------------------------------------------------- Luiz Henrique de Figueiredo internet: lhf@aries5.uwaterloo.ca Computer Systems Group bitnet: lhf@watcsg.bitnet University of Waterloo ------------------------------------------------------------------------------- eof