Content deleted Content added
Line 33:
2 ^ 16, but holding the result as floating point) gives 6.71999.
The correct floating point result is of course 6.72.
== Re-Scaling after Multiplication ==
The example above for a B16 multiplication is a simplified example. Re-scaling
depends on both the B scale value and the word size. B16 is often used in 32 bit systems because
it works simply by multipling and dividing by 65536 (or shifting 16 bits).
Consider the Binary Point in a 32 bit word thus:
0 1 2 3 4 5 6 7 8 9
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
Placing the binary point at 0 gives a range of -1.0 to 0.999999.
Pacing the binary point at 1 gives a range of -2.0 to 1.999999 and so on.
When using different B scalings the complete B scaling formula must be used.
Consider a 32 bit word size, and two variables, one with a B scaling of 2 and the other with a scaling of 4.
1.4 @ B2 is 1.4 * (2 ^ (wordsize-2-1)) == 1.4 * 2 ^ 29 == 0x2CCCCCCD
Note that here the 1.4 values is very well represented with 20 fraction bits ! This is why B scaling
is always more accurate than floating point of the same wordsize.
Now a larger number 15.2 at B4.
15.2 @ B4 is 15.2 * (2 ^ (wordsize-4-1)) == 15.2 * 2 ^ 27 == 0x79999999A
Multiplying these 32 bit numbers give the 64 bit result 0x1547AE14A51EB852
This result is in B7 in a 64 bit word. Shifting it down by 32 bits gives the result in
B7 in 32 bits.
0x1547AE14
To convert back to floating point, we need to divide this by (2^(wordsize-7-1)) == 21.2800000099
Various scalings maybe used. B0 for instance can be used to represent
|