ts-7000
[Top] [All Lists]

Re: [ts-7000] floating point corruption?

To:
Subject: Re: [ts-7000] floating point corruption?
From: "Daniel Serpell" <>
Date: Wed, 27 Feb 2008 15:16:10 -0300
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/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU