2的补重馏分presentation? [英] 2's complement representation of fractions?

查看:113
本文介绍了2的补重馏分presentation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点失去了对这个。我需要使用两个小数位
0(A-1)(A-2)

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

这样,现在我可以使用 .00 0.01 0.10 0.11
但我需要负数(2的补数)也,故将 0.10 - 5 ?或者会是 - 25
同样与 0.11 ,这将是 - 75 ?或者会是 - 5
我是pretty肯定它会在两种情况下前者,但我不能完全肯定的。

Like that, now I can use .00 .01 .10 and .11 But I need negative numbers (in 2's complement) also, so would .10 be -.5 ? or would it be -.25 ? The same with .11 , that would be -.75? or would it be -.5 ? I'm pretty sure it would be the former in both cases, but I'm not entirely positive.

推荐答案

在二进制补码,全部设置为1负数的最显著位让我们假设你存储这些数值为8位, 2向右侧的二进制小数点。

In two's complement notation, all of the most significant bits of a negative number are set to 1. Let's assume you're storing these numbers as 8 bits, with 2 to the right of the "binary point."

根据定义, X + -x = 0 ,所以我们可以这样写:

By definition, x + -x = 0, so we can write:

0.5  +  -0.5 = 0.10 + 111111.10 = 0   // -0.5  = 111111.10
0.25 + -0.25 = 0.01 + 111111.11 = 0   // -0.25 = 111111.11
0.75 + -0.75 = 0.11 + 111111.01 = 0   // -0.75 = 111111.01

等。

使用8位这样,你可以存储数量最多

Using 8 bits like this, the largest number you can store is

011111.11 = 31.75

最小正数是

the least-positive number is

000000.01 = 0.25

至少负数是

the least-negative number is

111111.11 = -0.25

和最小(即,最负)是

100000.00 = -32

这篇关于2的补重馏分presentation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆