This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Floating point representation with Ecos


"Ramiro C. Carvalho" <ramiro.carvalho@uol.com.br> writes:

> Hi, everybody.
>
> I am experiencing problems exchanging floating point data between my Ecos
> target (ARM7 processor and gcc 4.0.1) and Matlab under Windows XP (which
> uses IEEE 754 standard).

ARM7 working in little-endian mode has big-endian order of 2 4-byte
words in double and little-endian order of bytes inside the words, while
ix86 has little-endian-everything. This doesn't depend on eCos or
Windows, -- it's entirely hardware incompatibility.

Fix your code running on ARM7 processor to output doubles in the
order that ix86 expect them. You need to swap 2 4-byte words of
double. Something like this:

void outDouble(double d)
{
  union U {
    double d;
    unsigned u[2];
  };
  union U u;
  u.d = d;
  outUnsigned(u.u[1]);
  outUnsigned(u.u[0]);
}

-- Sergei.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]