顽固位不会被设置为1.

Cas*_*sey 0 c binary ieee ieee-754

我有这个代码用于获取IEEE二进制数的尾数或值.

iFloat_t floatGetVal (iFloat_t x) {
  iFloat_t mantissa = (BITS == 16) ? (x & 0x03FF)
                      : (x & 0x007FFFFF);
    debug("%s: getVal before implicit 1", getBinary(mantissa));
    //mantissa = (BITS == 16) ? (mantissa | 0x04)
    //                : (mantissa | 0x008);
    mantissa = x | 0000010000000000;
    debug("%s: getVal after implicit 1", getBinary(mantissa));
    mantissa = (BITS == 16) ? (mantissa & 0x07FF)
                      : (mantissa & 0x00FFFFFF);
    if(floatGetSign(x) == 1) {
        mantissa = ~mantissa + 1;
    }
    return mantissa;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是当我尝试从数字63.125获取值时,这是相应的输出:

DEBUG iFloat.c[31] floatGetVal() 0000-0011-1110-0100: getVal before implicit 1
DEBUG iFloat.c[35] floatGetVal() 0101-0011-1110-0100: getVal after implicit 1
DEBUG iFloat.c[81] floatAdd() 0000-0011-1110-0100: bits of val_y after assignment
Run Code Online (Sandbox Code Playgroud)

这是我的预期输出:

DEBUG iFloat.c[31] floatGetVal() 0000-0011-1110-0100: getVal before implicit 1
DEBUG iFloat.c[35] floatGetVal() 0101-0111-1110-0100: getVal after implicit 1
DEBUG iFloat.c[81] floatAdd() 0000-0111-1110-0100: bits of val_y after assignment
Run Code Online (Sandbox Code Playgroud)

这是我的完整代码:

https://pastebin.com/w4UVzmUe

zch*_*zch 7

0000010000000000是八进制文字,而不是二进制文字,使用十六进制0x0400.