Newsgroups: comp.lang.c,comp.sys.super Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Type punning in C Message-ID: <1989Oct8.005808.11039@utzoo.uucp> Organization: U of Toronto Zoology References: <475@idacrd.UUCP> Date: Sun, 8 Oct 89 00:58:08 GMT In article <475@idacrd.UUCP> desj@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? ... > It doesn't seem that there is any equally straightforward way to >accomplish this in C. I don't want to involve pointers ... You might try unions. This is one of the things they're good for, albeit in a very implementation-specific way. (Not a problem here, since the operation is inherently implementation-specific.) If your compiler won't put unions into registers, complain to your supplier. -- A bit of tolerance is worth a | Henry Spencer at U of Toronto Zoology megabyte of flaming. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu