Article View: comp.lang.misc
Article #3905Re: Safety. Was: Re: Pointers
From: Fergus James HENDERSON
Date: Mon, 21 Dec 1992 20:41
Date: Mon, 21 Dec 1992 20:41
33 lines
1481 bytes
1481 bytes
hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
>The expression use_double(...), as
>I intend it, means that the bit pattern, or concatenated bit pattern,
>described in the parentheses is to be now used as a double number in
>any application. Therefore, in process(use_double(...)), process just
>assumes that what is presented to it is a double, just as the cast to
>double declares that the result is double.
I don't know why I bother, but here it is anyway...
In Gnu C:
#define use_double(var) ({ \
union { typeof(var) old; double new; } tmp; \
tmp.old = var; \
tmp.new \
})
In C++:
template<class T>
double use_double(T var) {
union { T old; double new; } tmp;
tmp.old = var;
return tmp.new
}
Satisfied, Mr. Rubin?
--
Fergus Henderson fjh@munta.cs.mu.OZ.AU
This .signature virus is a self-referential statement that is true - but
you will only be able to consistently believe it if you copy it to your own
.signature file!
Technical Details
Message-ID:
<9235707.2967@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjhReferences:
<1992Dec16.164821.19079@walter.bellcore.com> <BzD525.Ayv@mentor.cc.purdue.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) Subject: Re: Safety. Was: Re: Pointers Message-ID: <9235707.2967@mulga.cs.mu.OZ.AU> Sender: news@cs.mu.OZ.AU Organization: Computer Science, University of Melbourne, Australia References: <1992Dec16.164821.19079@walter.bellcore.com> <BzD525.Ayv@mentor.cc.purdue.edu> Date: Mon, 21 Dec 1992 20:41:28 GMT Lines: 33