Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How represent Floating Point Logarithm

70 views
Skip to first unread message

高野

unread,
Feb 2, 2019, 11:54:08 AM2/2/19
to
Hi,

I consider the floating point logarithm, f(x) = log_{e}x.
Floating number x > 0 can be represented as follows;
x = (2^{Fx - F0})*(1.Mx)

where Fx is fraction, and Mx is mantissa, respectively.
Then we can take log_{e}(x) as follows;
log_{e}(x) = log_{e}[2^{Fx - F0 - LM}*((1.MX)*2^{LM})]

where LM is a mantissa bit-field width, then this equation can be;

log_{e}(x) = (log_{e}2)log_{2}[2^{(Fx - LM - F0}*((1.Mx)*2^{LM}]
= (log_{e}2)[log_{2}2^{Fx - LM - F0}*((1.Mx)*2^{LM}]
= (log_{e}2)[log_{2}2^{Fx - LM - F0} + log_{2}(1.Mx)*2^{LM}]
= (log_{e}2)[(Fx - LM - F0) + log_{2}((1.Mx) << LM)]
= c0*[A + log_{2}B]

where,
c0 = log_{e}2,
A = Fx - (LM + F0): Integer
B = 1.Mx << LM
= {1.MZ, LM(0)}: Integer and greater than zero (concatenation with LM-bit zero)

Therefore, we can obtain log_{e}(x) with Int2Float(A), log_{2}(Int2Float(B)), addition, and finally constant (c0) float multiplication.
1) If log_{2}(float d) is reasonably implemented, logic circuit of this approach has high accuracy.
2) Or, if float_log_{2}(int B) is possible as logic circuit, then it is more easier to implement.

Does anyone know possibility of 1) and 2) ?

Best,
S.Takano

高野

unread,
Feb 2, 2019, 12:05:27 PM2/2/19
to
On Sunday, February 3, 2019 at 1:54:08 AM UTC+9, 高野 wrote:
> = {1.MZ, LM(0)}: (concatenation with LM-bit zero)

This is wrong.

Best,
S.Takano

MitchAlsup

unread,
Feb 2, 2019, 12:15:16 PM2/2/19
to
Ln2( ±0 ) = -∞
Ln2( -R ) = Quiet NaN, and signals the Operation exception.
otherwise:
ln2( x ) = ln2( 1.f×2^e )
= ln2( 1.f ) + ln2( 2^e )
= ln2( 1.f ) + e

So, you take the fraction of the floating point number, run fraction through
a polynomial and then add the debiased exponent. {You also perform a handful
of special checks in parallel.}

Taking the exponent and making it a FP fraction is easy in HW.

高野

unread,
Feb 2, 2019, 12:21:22 PM2/2/19
to
On Sunday, February 3, 2019 at 1:54:08 AM UTC+9, 高野 wrote:
> B = 1.Mx << LM
This should be
= {1, Mx}

Best,
S.Takano

高野

unread,
Feb 2, 2019, 12:44:55 PM2/2/19
to
Dear Mitch-san,

On Sunday, February 3, 2019 at 2:15:16 AM UTC+9, MitchAlsup wrote:
> ln2( x ) = ln2( 1.f×2^e )
> = ln2( 1.f ) + ln2( 2^e )
> = ln2( 1.f ) + e
>
> So, you take the fraction of the floating point number, run fraction through
> a polynomial and then add the debiased exponent. {You also perform a handful
> of special checks in parallel.}

! I missed fraction == mantissa, "fraction" in my comments should be "exponent".
Your suggestion is for 1), right?
I want a pipelined solution and want not to use the polynomial.

I think that int_log_{2}(B) is easy to implement.
Summation of position of one from MSB to LSB, is result, so we can tradeoff how many additions are taken for accuracy.

Best,
S.Takano

高野

unread,
Feb 2, 2019, 12:58:59 PM2/2/19
to
On Sunday, February 3, 2019 at 2:44:55 AM UTC+9, 高野 wrote:
> Summation of position of one from MSB to LSB, is result, so we can tradeoff how many additions are taken for accuracy.

If we do not care a cost, this can be implemented by adder-tree which input constant position number if the position has "1", otherwise input zero.

Best,
S.Takano

高野

unread,
Feb 2, 2019, 1:07:01 PM2/2/19
to
On Sunday, February 3, 2019 at 2:44:55 AM UTC+9, 高野 wrote:
> I think that int_log_{2}(B) is easy to implement.

This should be;
I think that int C = log_{2}(int B) is easy to implement.

ps.
USA people watch Super Bowl ?

Best,
S.Takano

高野

unread,
Feb 2, 2019, 1:14:13 PM2/2/19
to
On Sunday, February 3, 2019 at 2:58:59 AM UTC+9, 高野 wrote:
> If we do not care a cost, this can be implemented by adder-tree which input constant position number if the position has "1", otherwise input zero.

If this is high cost, then we can use an encoder at first level, after that adding the encoders' output.

Best,
S.Takano

高野

unread,
Feb 2, 2019, 2:07:50 PM2/2/19
to
I want to remove the constant c0 float multiply.
Any suggestion?

Best,
S.Takano

MitchAlsup

unread,
Feb 2, 2019, 2:24:53 PM2/2/19
to
Some do, some don't.

I might tune in when there are 3 minutes to go, but then again maybe not.
>
> Best,
> S.Takano

MitchAlsup

unread,
Feb 2, 2019, 2:26:53 PM2/2/19
to
On Saturday, February 2, 2019 at 11:44:55 AM UTC-6, 高野 wrote:
> Dear Mitch-san,
>
> On Sunday, February 3, 2019 at 2:15:16 AM UTC+9, MitchAlsup wrote:
> > ln2( x ) = ln2( 1.f×2^e )
> > = ln2( 1.f ) + ln2( 2^e )
> > = ln2( 1.f ) + e
> >
> > So, you take the fraction of the floating point number, run fraction through
> > a polynomial and then add the debiased exponent. {You also perform a handful
> > of special checks in parallel.}
>
> ! I missed fraction == mantissa, "fraction" in my comments should be "exponent".
> Your suggestion is for 1), right?
> I want a pipelined solution and want not to use the polynomial.
>
> I think that int_log_{2}(B) is easy to implement.

INT( Ln2( F ) ) = F<63:53> - 1023.

MitchAlsup

unread,
Feb 2, 2019, 2:33:06 PM2/2/19
to
What kind of accuracy are you needing?

If you want to meet IEEE 754-2008 specifications and have less than 1 ULP
of error you will need a 8-term polynomial after deciding which of 16
intervals the fraction lies within.

If you only need 32-bit IEEE then this can be done with a 3-term polynomial
and a 128-entry table or with a 4 term polynomial and a 16-entry table.

If you only need 16-bit IEEE then this can be done with a 2-term polynomial
and a 8-entry table.

MitchAlsup

unread,
Feb 2, 2019, 2:34:51 PM2/2/19
to
Finally, if you only need 8-bits of precision, then you can simply take
the fraction (8-bits in) and look up the answer in a table (8-bits out).

高野

unread,
Feb 2, 2019, 4:31:55 PM2/2/19
to
Mitch-san,

Give me time to understand this method.

Best,
S.Takano

高野

unread,
Feb 2, 2019, 4:42:59 PM2/2/19
to
>What kind of accuracy are you needing?

At first, I want to try to make a lossless based on modification of the equation.
Second, I want to add accuracy matters such as a rounding, logic circuit design matters.
Third, I want to add exceptions.

If polynomial operations are integer arithmetic then it is considerable, but if it is floating point arithmetic then I want not to use it.

Best,
S.Takano

MitchAlsup

unread,
Feb 2, 2019, 8:06:37 PM2/2/19
to
Everything INSIDE a floating point calculation unit is integer arithmetic.
A whole bunch of integer arithmetics conspire to deliver a floating point result.
>
> Best,
> S.Takano

高野

unread,
Feb 3, 2019, 2:38:48 AM2/3/19
to
Yes, I understand. I mean is that polynomial operation is whether float mult and float add based.

Best,
S.Takano

高野

unread,
Feb 3, 2019, 2:48:52 AM2/3/19
to
Example polynomial operation = sum_{i}^{N}c_{i}*f_{i}(x)

Best,
S.Takano
0 new messages