Re: float exponent




"cr88192" wrote:
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.

I never met 'pow' ;)
The idea behind the FPU may be a mantissa range from +2^64-1 to -2^64-1,
[the non existing 64th bit is assumed to be a 1 if not zero/tiny/denormal]
and a binary exponent that could be used as a bit-shift-counter (after
unbiasing) to work by seeing it as byte-offset and a modulo 8 shift.

The CPU, unfortunately, haven't got an instruction to shift larger memory
operands bitwise, so most use the Log/unLog way described at the end of
the x87-manual and this can make the whole FPU useless when precision
demands exceed the given <16 decimal digits. But the maximum precision
with this 63 bit mantissa is 18.9 digits (9.22...e18) anyway, without and
beside the weird rounding yet.


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.

This sound very familiar to me :)
Seems they wanted to hide their goodies, so only if one really got the
nerves and the time he may suceed in finding out how it works ...

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.

Define Array elements for multiple operands and results ?
Similar to the nominator/denominator pairs (used to save on divide).

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.

There are many math.pages on the net ... I found many interesting articles
by googling "binary & Taylor".

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

My calculator doesn't use the FPU nor the 2^-n IEEE standard, I work with
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, but it also can
(slow) calculate and create LUTs or whatsoever may be desired or needed.

__
wolfgang



.



Relevant Pages

  • 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)
  • float exponent
    ... anyone here know how to go about computing floating point exponents?... ... 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. ... all this is for my compiler, for which I have now added an exponent operator. ...
    (alt.lang.asm)