float exponent



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...


.



Relevant Pages

  • Re: float exponent
    ... anyone here know how to go about computing floating point exponents ... similar could be used for certain constant/integer floating ... integers up to 512 bit fix-pt and my exponents are decimal valued. ... In the general case it uses a set of LUTs and constants, ...
    (alt.lang.asm)
  • Re: float exponent
    ... anyone here know how to go about computing floating point exponents (like in ... f2xm1 and fyl2x would almost seem to provide something, ... all this should work pretty well though, as most of the time, exponents are ... I know basically nothing about quaternions, ...
    (alt.lang.asm)
  • Re: Working with exponents in code
    ... want to consider multiple multiplies. ... Pow() under the covers anyway. ... "Stefan L" wrote in message ... > Am I blind or is there just no "easy" way to use exponents? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: inline power function replacement
    ... You're not writing a macro. ... Presumbly "pow" should be checking for integer exponents... ... Frederick Gotham ...
    (comp.lang.c)
  • double a = 1e-10;?
    ... Just a humble question, I tried to assign a real number with exponents ... The compiler will in turn complain about the undefined 'e'. ...
    (comp.lang.c)