Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!xanth!kremer From: kremer@cs.odu.edu (Lloyd Kremer) Newsgroups: comp.lang.c Subject: Re: Type punning in C Summary: can also use pointers Message-ID: <10236@xanth.cs.odu.edu> Date: 20 Oct 89 19:40:54 GMT References: <475@idacrd.UUCP> <11242@smoke.BRL.MIL> <605@maytag.waterloo.edu> <6310@arcturus> Organization: Old Dominion University, Norfolk, Va. Lines: 22 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. Another way would be to back off one level of indirection, and transfer the bit pattern by means of pointers to the respective objects. Example: float f; int i; /* assign f */ i = *(int *)&f; /* transfer bit pattern from f to i */ -- Lloyd Kremer ...!uunet!xanth!kremer Have terminal...will hack!