This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

RE: floating point library problems ...


Thanks to Luke, Greg, Philip and Kai for the your comments and suggestions.
In the mean time this perticular problem is more or less solved. When I
compiled the C sources I used it with the -m68000 flag to indicate to
produce the 16 bit code (my target is an MC68VZ328). But I had not added the
flag to the linker stage (that was stupid of course), and thus the linker
used the default 32 bit libraries (for 68020 and onward). That whas the
reason why multply worked and sin() and sqrt() functions not.

Now my floating point functions work fine, however i an intresting situation
whyle printing out the floating point value appears.

void test(void)
 {
  double fpval;

  fpval = sqrt(M_PI);
  printf("sqrt(M_PI) = %f\n",fpval);
 }

The results I get are "sqrt(M_PI) = 1.>?LMMd", the "772454" has been
transformed into ">?LMMd" and thus unreadable.

Then I modified the program so that it would print out the abtained value as
an integer number that has been multiplyed with 1000000.

void test(void)
 {
  double fpval;
  int intval;

  fpval = sqrt(M_PI);
  printf("sqrt(M_PI) = %f\n",fpval);
  intval = fpval * 1000000;
  printf("intval = %d.\n",intval);
 }

The output (is correct this time):

sqrt(M_PI) = 1.772454
intval = 1772453.

Why is the floating point printed out correcty when a integer operation
follows (when I remove the integer part i get unreadable decimal part) ?

An interesting detail is the following: The values are printer out on an a
graphic LCD screen (which works fine). When a floating point fuction is
called, some dotted lines appeare on the screen, indicating that the program
writes data somewhere in the LCD framebuffer memory when it should not. I
have checked the memory map, an this should not happen. I think that
somthing to do with the floating point subroutines is not properly
initialised. But what ? ...

Kind regards,

Ken

-----Original Message-----
From: lgd@virata.com [mailto:lgd@virata.com]On Behalf Of Luke Diamand
Sent: donderdag 14 september 2000 13:32
To: ken@sdt.be
Cc: crossgcc@sourceware.cygnus.com
Subject: Re: floating point library problems ...


Could you have some kind of problem with the endianness of doubles? See
if you get the same problem with floats and work from there.

At least on ARM, gcc assumes doubles are big-endian (the words are in
the opposite order to the one you would expect, but within a word they
are little endian). These leads to some weird results for the unwary...


Luke Diamand

Ken DESMET wrote:
>
> Hi all,
>
> I have build a cross compiler to a m68k target with the newlib-1.8.1
> library.
>
> When i compile small test programs with simple floating point functions
like
> multiplications, they do work fine. More complex floating point functions
> like sqrt() and sin() do not seem to function. They simply hang/never
return
> ...
>
> Any suggestions what could be the cause of this problem ?
>
> Greetings,
>
> Ken

--
Virata http://www.virata.com
Cambridge
Tel: +44 1223 566919      Fax: +44 1223 566915


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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