Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!adm!weiser.pa@Xerox.COM From: weiser.pa@Xerox.COM Newsgroups: comp.unix.wizards Subject: casting to float without converting to float? Message-ID: <11171@brl-adm.ARPA> Date: 7 Jan 88 20:57:56 GMT Sender: news@brl-adm.ARPA Lines: 19 I have the following problem: I have a value which I happen to know has the proper bits to represent a floating point number (either 32 or 64). However, it is of type int. I would now like to tell the C compiler to treat this thing as a float. How can I do it without taking the address of the thing (which may not have an address because it is in a register or is an expression) or using a subroutine call (for which I do not wish to pay the cost)? (If I could take an address, then the solution is: *(float *)foo).) (Needless to say, the following does NOT work: (float)foo, because it actually does a conversion of the integer foo into a float. I don't want a conversion, but rather I want the compiler to just trust me that I am handing it bits that it should consider to be a float.) Thanks for any help. Currently I'm working around the problem by using assembler in-lines as supported by Sun, but I'd like a less vendor independent method. -mark