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 is encoded as a pair . Here is a sign bit and 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: and , and the result's sign bit is . Sums depend on the signs. Let and . If and have the same sign, then . If they have opposite signs, then , and the result takes the sign of . When , the result is zero.
Key Formula
Where:
- = Stored base-2 logarithms of the magnitudes, so
- = Stored logarithm of the product (this rule works for any signs)
- = Stored logarithm of the sum. The displayed rule applies only when both numbers are positive. For opposite signs, replace with .
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.
Step 2: Multiply by adding the stored logarithms. The chip performs one fixed-point addition and no multiplication. Decode the result to check it.
Step 3: Add the numbers with the same-sign rule. Use the larger value, 32, as , so . Real hardware gets the correction term from a lookup table or an approximation.
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 ) 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 as the code for .
Correction: Adding logarithms gives the product: , not 40. A sum needs the correction term . Use the plus sign for same-sign operands and the minus sign for opposite signs.
