Hi,
On Wed, Feb 27, 2008 at 10:19 AM, Heinrich du Toit
<> wrote:
>
> I've compiled a program that does some floating point stuff.
> It also communicates with my linux host PC via network.
>
[...]
>
> I've established that network communication is not the problem.
>
> It seem that floating point is corrupt.
>
> When I send from the ARM to the host PC the number 1.
> I get back 5.29981e-315 :-/
This seems an endianness problem, because if you swap the
words in a double with the number "1", you get exactly your number:
------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
union {
double d;
int i[2];
} a,b;
if(argc>1)
a.d = atof(argv[1]);
else
a.d = 1;
b.i[0] = a.i[1];
b.i[1] = a.i[0];
printf("Original: [%08x%08x] %g\n",a.i[0],a.i[1],a.d);
printf("Swapped: [%08x%08x] %g\n",b.i[0],b.i[1],b.d);
return 0;
}
------------------------------------------------
Try running the program above, it will show the number 5.29981e-315
I'd look on the network protocol, as you probably are not swapping
bytes correctly from network/host.
Daniel.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|