user15695: I am receiving 8 bytes from serial.
I want to convert and save in double variable. 
This is how i tried.
union u_data
    {
        byte b[4];
        double fval;
    } u;

double BytesToDouble (byte b8,byte b7,byte b6,byte b5,byte b4,byte b3,byte b2,byte b1)
{   
    u.b[0] = b1;
    u.b[1] = b2;
    u.b[2] = b3;
    u.b[3] = b4;
    u.b[4] = b5;
    u.b[5] = b6;
    u.b[6] = b7;
    u.b[7] = b8;
 return u.fval;
}

But i am getting 0.00. Because here double size is 4 bytes.
Is there is any other way to do this?
Thanks

user368: avr-gcc doesn't support binary64. You can use 8 bytes to treat it as an opaque data type, but attempting to manipulate it beyond manually converting to/from binary32 will be naught but pain.

user4143: In the Arduino there is no such thing as a double. A double is just another name for a float.
So you will have to either:

Manually interpret the double format data and calculate that into a float value, or
Send the value as some other format, such as float (32-bit), ASCII text, or (a selection of) integer values.

Since you can't actually use anything more than float, sending data with a higher resolution is pointless, so you are probably best off just sending it as a float.

15695: <p>I am receiving 8 bytes from serial.</p>

<p>I want to convert and save in double variable. </p>

<p>This is how i tried.</p>

<pre><code>union u_data
    {
        byte b[4];
        double fval;
    } u;

double BytesToDouble (byte b8,byte b7,byte b6,byte b5,byte b4,byte b3,byte b2,byte b1)
{   
    u.b[0] = b1;
    u.b[1] = b2;
    u.b[2] = b3;
    u.b[3] = b4;
    u.b[4] = b5;
    u.b[5] = b6;
    u.b[6] = b7;
    u.b[7] = b8;
 return u.fval;
}
</code></pre>

<p>But i am getting 0.00. Because here double size is 4 bytes.</p>

<p>Is there is any other way to do this?</p>

<p>Thanks</p>
 368: <p>avr-gcc doesn't support <a href="https://en.wikipedia.org/wiki/Double-precision_floating-point_format" rel="nofollow">binary64</a>. You can use 8 bytes to treat it as an opaque data type, but attempting to manipulate it beyond manually converting to/from binary32 will be naught but pain.</p>
 4143: <p>In the Arduino there is no such thing as a double. A double is just another name for a float.</p>

<p>So you will have to either:</p>

<ol>
<li>Manually interpret the double format data and calculate that into a float value, or</li>
<li>Send the value as some other format, such as float (32-bit), ASCII text, or (a selection of) integer values.</li>
</ol>

<p>Since you can't actually use anything more than float, sending data with a higher resolution is pointless, so you are probably best off just sending it as a float.</p>
