You are on page 1of 2

Background:

Computers are really good at subtraction, addition, and multiplication,

Calculati ng the magic constant for LNS:


LNS representati on is very similar to floati ng point representati on, with
very similar value. Using LNS numbers, we can calculate the exact value
for the inverse square root of a decimal.
LNS value(u = input bits): 2^w/2^23 – 127; The value of the inverse
square root would be: (2^w/2^23 – 127)^-1/2
We set an LNS value representati on equal to the inverse square root
value representati on(x = the inverse square root bits):
2^x/2^23 – 127 = (2^w/2^23 – 127)^-1/2
By simplifying the equati on for x, we can find the functi on that will alter
the unintepreted bits of the input LNS value directly to the unintepreted
bits of the output inverse square root value. Simplifying the equation
would give us:
x/2^23 = (w/2^23)/-2 + 190.5
x/2^23 = (w/-2)/2^23 + 190.5
x/2^23 = w/-2 + 190.5*2^23
x = 190.5*2^23 – w/2
Finally:
x = 1598029824 – w/2.
The division by two can be replaced by bitshift operations of w to the
left , which is fast and has the same eff ect of dividing by two.
Where w is the raw bit value for the input value, x is the raw output bit,
and 1598029824 is the magic constant(for LNS, in decimal). This functi on
will give us the exact functi on for LNS inverse square root.

You might also like