Path: utzoo!attcan!uunet!ginosko!uakari.primate.wisc.edu!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.lang.c,comp.sys.super Subject: Re: Type punning in C Message-ID: <2325@munnari.oz.au> Date: 8 Oct 89 07:10:54 GMT References: <475@idacrd.UUCP> Sender: news@cs.mu.oz.au Lines: 16 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? union { long i; float x; } pun; pun.i = the_integer_to_be_converted; the_single_precision_result = pun.f; > One frequently (well, occasionally) needs to do this to implement certain > bit manipulations efficiently on Cray computers and other vector machines ... Just which operations are these? If the operations are meaningful functions of floating-point numbers (e.g. things like ilogb() copysign() nextafter()) it might make more sense to ask Cray to put _those_ in their library. I really would like to know what the operations are.