


|
Here are some useful equations and rules for those who need to perform fixed-point scaled integer arithmetic. “Are there any such people?” I hear you ask. Well, clearly if you had to ask, you’re not involved in doing it! However, the great advantage this method of performing calculations has is SPEED. Floating point operations are always going to be a lot slower. The equations are for use in determining the resultant scaling after a calculation, or for determining the appropriate scaling to use, or to convert between different types of scaling. |
|
· |
MSB = the value of the most significant bit of a binary word |
|
· |
SMS = the number representing the value after scaling |
|
· |
N = the number |
|
· |
B = the B (binary power) scaling |
|
· |
LSB = the value of the least significant bit |
|
· |
L = the word length in bits |
|
· |
K = 1 for two’s complement, 0 for unsigned |
|
· |
m1 = scaling factor 1 as an MSB |
|
· |
m2 = scaling factor 2 as an MSB |
|
· |
s3 = Scaling factor 3 as a B-scaling |
|
· |
X and Y = scaled numbers |
|
· |
E = number of bits per digit |
|
· |
H = number of digits |
|
|
|
1 |
Convert N to SMS SMS = N*2^(L-K)/MSB SMS = N/LSB |
|
2 |
Convert SMS to N N = SMS*MSB/2^(L-K) N = SMS*LSB |
|
3 |
MSB = N*2^(L-K)/SMS |
|
4 |
MSB = 2^(L-K)/2^B |
|
5 |
Max B-scaling for a number B = (L - K - 1) - INT(LOG(N)/LOG(2)) |
|
6 |
New scale of factors X @ m1, Y @ s3 Result of X*Y is XY @ m1/s3 |
|
7 |
New scale of factors X @ m1, Y @ m2 Result of X*Y is XY @ m1*m2/2^(L-K) |
|
8 |
No. of bits per digit where D is the number base E = LOG(D)/LOG(2) |
|
9 |
No. of digits H = INT(L/E + 0,5) |