MariuszK said:
Hello,
Actually I found next solution, but it is not precise:
2^x ~ 2^INT(x)*(1+FRAC(x))
Where:
INT(X) - integer part of x
FRAC(X) - fraction part of x
example x= 43.125
INT(43.125) = 43
FRAC(43.125)= 0.125
Any other idea?
Mariusz
I think you can use the fact that
2^(a+b) = 2^a * 2^b
You only have to deal with the fractional part
by subtracting out the integer part of the
exponent, and that's how many places you shift
the result left.
To produce the effect of the fractional part,
you could use an array of multipliers, each bit
in the fractional part either multiplying by 1 or
by a factor.
So in binary fractions:
..1 = 2 raised to the power of 1/2.
..01 = 2 raised to the power of 1/4
..001 = 2 raised to the power of 1/8
You have a fixed point representation of 2^.5, 2^.25,
2^.125, etc. If the bit in the exponent is 1, you
multiply by the appropriate constant, otherwise
you multiply by 1, and feed the result forward.
so in binary: 10^.1001
is in decimal 2^.5 * 2^.0625
This is similiar to a multiplier circuit itself,
where it's a serial array of optional adders,
only it's a serial array of optional multipliers.
You're helped because each multiply has one
side always a constant value.
IIRC, in one of these newsgroups, someone else
recently suggested something very similiar, but
if I read his suggestion correctly his approach was
to do additions for each fractional bit. This wouldn't
work.
Hope this is useful.
-Dave