Multiplication of a fixed point of unsigned numbers

I am trying to solve the fixed point multiplication problem. 32 bit numbers. My architecture is 8 bit. So here it is:

  • I use 8.8 notation, i.e. 8 for an integer, 8 for a fraction.

  • I have an A78 that is 10.468. I take its two additions, and the answer is FFFFF588, which I truncated to 16 bits as F588 and saved it. The reason is that I only want to multiply two, 2 byte numbers.

  • Now when I multiply this F588 (negative 10.42 or 0x0A78) by 0xFF4B, which is two compliments of 0x00B5 (0.707), the answer should be 0x0766. Or something like that.

What I get on the other hand is the 66D8.

Now here's where it’s interesting: if I save a negative B5 result in two compliments in 32 bits, I get 0xFF5266D8, which I shift to the right by 8 bits, then truncate to 16 bits, and the answer is 0x5266.

On the other hand, if I instead store a negative 10.42 in 32 bits, I get 0xF58F66D8, which after shifting 8 bits and truncating becomes 8F66.

But, if I store both numbers in 32-bit formats, only then I get the correct result after the offset and truncation, which is 0x0766.

Why is this happening? I understand that information loss is essential when we go from 32 to 16 bits, but 0x07 is very different from 0x55. I will be absolutely grateful for the answer.

+5
source share
1 answer

. 16- , x y, 16- . 16- 32- . 32 , 65536-x 65536-y. (, 0xa78, , 0xfffff588, , 0xf588, 0x10000-0xa78.)

65536 • 65536 - 65536 • x - 65536 • y + x • y.

65536 • 65536 - 2 32 , 32- 2 32. - 65536 • x - 65536 • y + x • y.

: x • y - 16- , 16 32 . - 65536 • x - 65536 • y, .

, 32 . , 0xa78, 0xfffff588. , 0xf588. , 0xfffff588 0xffffff4b, 0x766d8, 0x766, .

, 16- , . , 15 16 31. - 16- 16- , 16- 32- .

+4

All Articles