CSAPP——b站视频第三节

老规矩,先上视频链接开始观看

主要内容:

Floating Point

  1. 二进制小数表示方法和10进制完全相同,只是权值变了
    以上的方法的局限性:
    1.只能代表x/2^k这种数字
    2.如果数据的位数有限,我们只能表示大一点的或者小一些但精度准确
    故浮点数是可以移动小数点的表示方法,可以最大限度以展示数据精度

  2. Numerical Form: ( 1 ) s M 2 E (-1)^{s}M2^{E}
    s:determines whether number is negative or positive
    M:normally a fractional value in range [1.0,2.0)
    E:weights value by power of two

  3. IEEE provides two different kinds of floating-point: Single precision 32 bits and Double precision 64 bits在这里插入图片描述

  4. “Normalized” Values:
    1.exp!=00000…0000 and !=11111…1111当作特殊情况处理
    2.举个栗子,当E的值变化在:-126~127之间时,我们用exp代替E,这样就可以用正数代替有负数的范围.exp 和E的关系就是,E=EXP-Bias(偏置值)
    3.需要注意的是,M一定是一个1.XXXX的数,在表示浮点数时把那个隐藏的1省略了,这样也省下了一个数据位
    在这里插入图片描述

  5. Normalized Encoding Example
    举个例子:15213.0
    在这里插入图片描述
    标准化顺序:
    求value,转成二进制,“二进制的科学记数法”;
    求significand,把隐藏的1舍去,后面补0;
    求exp,E+Bias;
    算上符号位,得到resault

  6. attention:
    ① 0<=EXP<=255
    ② -127<=E<=128
    ③denormalized value can represent the number near 0, there is no implied 1, the significant m is represented exactly is encoded identically in the frac filed . and exp = 1 - bias .
    ④when exp all 1s and frac all 0s, this represents the value infinity.overflow~
    ⑤the exp is all 1s but the frac is no 0 , this is called not a number
    ⑥if you want to understand ,do some examples

一些课本例题,等我课本看到这里再更。
本人小白,有啥错误,欢迎留言指出!一起讨论进步!

发布了8 篇原创文章 · 获赞 5 · 访问量 153

猜你喜欢

转载自blog.csdn.net/qq_41650371/article/details/104405972