float exponent
- From: "cr88192" <cr88192@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Oct 2007 15:42:32 +1000
just wondering:
anyone here know how to go about computing floating point exponents (like in 'pow')?...
sadly, this one escapes me, and I can't find more info.
f2xm1 and fyl2x would almost seem to provide something, but f2xm1 only works over a very small range.
attempting to disassemble pow has not turned out well, as I think it goes off in some dll somewhere, and each place I look seems to jump somewhere else.
ok, maybe I could rig up an interactive disassembler if I really needed it, but maybe someone here might know...
even more useful:
if whoever knows, also knows about a form for complexes.
and, if I am really lucky, for quaternions.
all this is for my compiler, for which I have now added an exponent operator. sadly, at present, since I have not figured this out, I have ended up having to deal with the float case by generating calls to pow and cpow.
as for the quaternion exponent (if I can find info on such a beast), is almost gueranteed to be implemented as a hidden function call though.
well, at least the integer case went well:
x^y in my compiler is written as x`y.
x`y (2 values) is implemented as a small loop, and has a cost of O(y).
if y is a literal, however, small cases are special, and in the general case it takes about O(log2 y), or, more correctly:
O(log2 y + y mod 2^(log2 y)).
potentially, similar could be used for certain constant/integer floating point exponents (such as 1/2, 0, 1, and other integers). as such, secretly calling 'pow' as the fallback case.
all this should work pretty well though, as most of the time, exponents are probably going to look something like:
'x`2' or 'x`3', which can luckily be nicely handled with good old multiplies...
or something...
.
- Follow-Ups:
- Re: float exponent
- From: James Van Buskirk
- Re: float exponent
- From: Eugene . Styer
- Re: float exponent
- From: Wolfgang Kern
- Re: float exponent
- Prev by Date: Re: Slow nasm
- Next by Date: Real Mode,16 bit Programming (Intel x86) on Windows XP?
- Previous by thread: 64 bit
- Next by thread: Re: float exponent
- Index(es):
Relevant Pages
|