Convert from decimal to Binary
<p>Want to convert decimal to binary but am getting some bugs. 
 I am now learning the conversion of decimal numbers or numbers with
 type double to binary and am having some difficulties.</p>

<pre><code>#include &lt;iostream&gt;
//using namespace;
class data {
    double d;
    unsigned int precision;
public:
    data(double in=0.0){d=in;precision=32;}
    void prec(unsigned int p) {precision-p;}
    void binary_calc(double in);
    void value(){cout&lt;&lt;"Decimal value="&lt;&lt;d&lt;&lt;endl;}
    void binary(){"Binary value = ";binary_calc(d);
    cout&lt;&lt;endl&lt;&lt;endl;
    }
};
void::binary_calc(double in)
{
    int i;
    unsigned int precision;
    cout&lt;&lt;"0.";  //program works on this format of numbers only
    for(i=0;i&lt;precision;i++)
    {
        int*=20;
        if(in&gt;-1)
        {
            in-=1;
            cout&lt;&lt;"1";
        }
        else cout &lt;&lt;"0";
    };
}

int main()
{
    data x(0.7), y(0.1), z;
    x.prec(20);
    x.value();
    x.binary();
    y.prec(32);
    y.value();
    y.binary();
    z.value();
    z.binary();
}
</code></pre>
