2's complement representation of fractions?

后端 未结 3 1705
别跟我提以往
别跟我提以往 2021-01-21 03:02

I\'m a little lost on this. I need to use two fractional bits 0.(a-1)(a-2)

Like that, now I can use .00 .01 .10 and .11 But I nee

3条回答
  •  滥情空心
    2021-01-21 03:12

    A number stored in two's complement inverts the sign of the uppermost bit's magnitude (so that for e.g. a 16-bit number, the upper bit is -32768 rather than +32768). All other bits behave as normal. Consequently, when performing math on multi-word numbers, the upper word of each number should be regarded as two's-complement (since its uppermost bit will be the uppermost bit of the overall number), but all other words in each number should be regarded as unsigned quantities.

    For example, a 16-bit two's complement number has place values (-32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, and 1). Split into two 8-bit parts, those parts will have place values (-32768, 16384, 8192, 4096, 2048, 1024, 512, and 256); and (128, 64, 32, 16, 8, 4, 2, and 1). The first set of values is in a two's complement 8-bit number, times 256; the latter set is an unsigned 8-bit number.

提交回复
热议问题