Mathwords logoMathwords

Logarithmic Number System — Definition, Formula & Example

A logarithmic number system (LNS) is a way for computers to store a number as its base-2 logarithm plus a sign bit. Because of this, multiplying two numbers only requires adding their stored logarithms.

In an LNS, a nonzero real number xx is encoded as a pair (sx,ex)(s_x, e_x). Here sxs_x is a sign bit and ex=log⁡2∣x∣e_x = \log_2|x| is stored as a fixed-point number with a set count of integer and fractional bits. Zero has no logarithm, so it needs a separate flag. Products and quotients are exact: exy=ex+eye_{xy} = e_x + e_y and ex/y=ex−eye_{x/y} = e_x - e_y, and the result's sign bit is sx⊕sys_x \oplus s_y. Sums depend on the signs. Let ∣x∣≥∣y∣|x| \ge |y| and d=ey−ex≤0d = e_y - e_x \le 0. If xx and yy have the same sign, then ex+y=ex+log⁡2(1+2d)e_{x+y} = e_x + \log_2(1 + 2^{d}). If they have opposite signs, then ex+y=ex+log⁡2(1−2d)e_{x+y} = e_x + \log_2(1 - 2^{d}), and the result takes the sign of xx. When x=−yx = -y, the result is zero.

Key Formula

exy=ex+ey,ex+y=ex+log⁡2 ⁣(1+2 ey−ex)for x≥y>0e_{xy} = e_x + e_y, \qquad e_{x+y} = e_x + \log_2\!\left(1 + 2^{\,e_y - e_x}\right) \quad \text{for } x \ge y > 0
Where:
  • ex,eye_x, e_y = Stored base-2 logarithms of the magnitudes, so ex=log⁡2∣x∣e_x = \log_2|x|
  • exye_{xy} = Stored logarithm of the product (this rule works for any signs)
  • ex+ye_{x+y} = Stored logarithm of the sum. The displayed rule applies only when both numbers are positive. For opposite signs, replace 1+2d1 + 2^{d} with 1−2d1 - 2^{d}.

Worked Example

Problem: An LNS chip stores the positive numbers 8 and 32. Use only operations on the stored logarithms to find their product and their sum.
Step 1: Encode each number as its base-2 logarithm. Both numbers are positive, so both sign bits are 0.
e8=log⁡28=3,e32=log⁡232=5e_8 = \log_2 8 = 3, \qquad e_{32} = \log_2 32 = 5
Step 2: Multiply by adding the stored logarithms. The chip performs one fixed-point addition and no multiplication. Decode the result to check it.
e8⋅32=3+5=8,28=256e_{8 \cdot 32} = 3 + 5 = 8, \qquad 2^{8} = 256
Step 3: Add the numbers with the same-sign rule. Use the larger value, 32, as xx, so d=3−5=−2d = 3 - 5 = -2. Real hardware gets the correction term from a lookup table or an approximation.
e8+32=5+log⁡2 ⁣(1+2−2)=5+log⁡21.25≈5.3219,25⋅1.25=40e_{8+32} = 5 + \log_2\!\left(1 + 2^{-2}\right) = 5 + \log_2 1.25 \approx 5.3219, \qquad 2^{5}\cdot 1.25 = 40
Answer: The product is stored as 8, which decodes to 256. The sum is stored as about 5.3219, which decodes to 40. The product took a single addition. The sum needed the nonlinear correction term.

Why It Matters

An LNS is the reverse of floating point in terms of cost. Multiplication and division are cheap and exact, square roots (halve exe_x) and integer powers are cheap, while addition is the hard operation. That is why designers of low-power chips for digital signal processing and neural-network inference study LNS, since multiplications dominate those workloads. A slide rule applied the same idea mechanically.

Common Mistakes

Mistake: Adding the stored logarithms to get a sum, for example treating 3+5=83 + 5 = 8 as the code for 8+328 + 32.
Correction: Adding logarithms gives the product: 28=2562^8 = 256, not 40. A sum needs the correction term log⁡2(1±2d)\log_2(1 \pm 2^{d}). Use the plus sign for same-sign operands and the minus sign for opposite signs.

Related Terms