Article View: comp.lang.misc
Article #1313Re: Compiler Costs
From: Peter da Silva
Date: Mon, 09 Jul 1990 12:17
Date: Mon, 09 Jul 1990 12:17
24 lines
1215 bytes
1215 bytes
In article <2324@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
> The function is frexp(x,&n). The argument x is a double precision floating
> point number. The result is to be that number scaled down by a power of
> 2 so that the absolute value is between .5 and 1, with the power stored in
> the location &n.
I suspect that something like this will work:
double frexp(x,n)
double x;
int *n;
{
x = NORMALISE(x);
*n = ((long *)&x)[EXPONENT_WORD] & EXPONENT_BITS;
((long *)&x)[EXPONENT_WORD] &= ~EXPONENT_BITS;
return x;
}
You didn't say it had to be portable C. For most machines this will come
down to 2 or 3 instructions, given a decent compiler.
--
Peter da Silva. `-_-'
+1 713 274 5180.
<peter@ficc.ferranti.com>
Technical Details
Message-ID:
<8OJ4M.4@ficc.ferranti.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!cs.utexas.edu!texbell!ficc!peterReferences:
<1797@apctrc.UUCP> <103726@convex.convex.com> <2324@l.cc.purdue.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!cs.utexas.edu!texbell!ficc!peter From: peter@ficc.ferranti.com (Peter da Silva) Newsgroups: comp.lang.misc Subject: Re: Compiler Costs Message-ID: <8OJ4M.4@ficc.ferranti.com> Date: 9 Jul 90 12:17:26 GMT References: <1797@apctrc.UUCP> <103726@convex.convex.com> <2324@l.cc.purdue.edu> Reply-To: peter@ficc.ferranti.com (Peter da Silva) Organization: Xenix Support, FICC Lines: 20