1.二进制浮点数依然是小数,且0.625-0.101 (2^-1+2^-2+2^-3)=0.625,转化的时候是相乘2的

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i = 2;
    double a;
    cin >> a;
    int sum = 0; char ch[100] = "0.";
    while (a != 0)
    {
        a = a * 2;
        if (a >= 1)
        {
            ch[i] = '1';
            a--;
        }
        else
            ch[i] = '0';
            i++;
    }
    if (i <= 34) {


        for (int j = 0; j < i; j++)
            cout << ch[j];
    }
    else
        cout << "error";
    return 0;
}