Convert double value from little endian to Big endian
<p>I am converting from little endian to big endian and back to little checking<br>
    is it right or wrong please help me</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;netinet/in.h&gt;


double dx = 122992001003000;

//A method little to big endian

double bEndian(double d) {

    int *p0 = (int *) &amp;d;
    int *p1 = p0 + 1;

    printf("1: %x %x\n", *p0, *p1);

    int tmp = *p1;
    *p1 = htonl(*p0);
    *p0 = htonl(tmp);

    printf("2: %x %x\n", *p0, *p1);

    return *(double *)p0;
}

//A method  big to little endian

double lEndian(double d) {
    int *p0 = (int *) &amp;d;
    int *p1 = p0 + 1;

    printf("3: %x %x\n", *p0, *p1);

    int tmp = *p1;
    *p1 = ntohl(*p0);
    *p0 = ntohl(tmp);

    printf("4: %x %x\n", *p0, *p1);

    return *(double *)p0;
}

int main (int argc, char *argv[]) 
{       
    double d1 = bEndian(dx);

    double d2 = lEndian(d1);

    printf("5: %.0f\n", d2);

    if ((*(double*) &amp;d2) == dx)
      printf("6: %.0lf\n", *(double*) &amp;d2);
    else
      printf("7:%d\n", d2);

    return 0;
}
</code></pre>

<p>some time it give me result 122992001003129 why?
 also using ntohl or htonl have no difference ?? is it only for convention 
i.e. network to host and host to network</p>