This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Floating point problems with 68000 (no FPU)
- From: "Doug Broadwell" <dougb at value dot net>
- To: "J. Johnston" <jjohnstn at redhat dot com>, "Joel Sherrill" <joel dot sherrill at OARcorp dot com>
- Cc: "Newlib Mail List" <newlib at sources dot redhat dot com>
- Date: Tue, 19 Nov 2002 16:07:43 -0800
- Subject: Re: Floating point problems with 68000 (no FPU)
- Organization: DBA Associates
- References: <001101c28f44$9e3867c0$3cfea8c0@dba03> <3DD95EC7.98ED24BF@OARcorp.com> <3DD979A8.C21F832E@redhat.com>
- Reply-to: "Doug Broadwell" <dougb at value dot net>
Thank you.
Including math.h did the trick.
Doug Broadwell
----- Original Message -----
From: "J. Johnston" <jjohnstn@redhat.com>
To: "Joel Sherrill" <joel.sherrill@OARcorp.com>
Cc: "Doug Broadwell" <dougb@value.net>; "Newlib Mail List"
<newlib@sources.redhat.com>
Sent: Monday, November 18, 2002 3:37 PM
Subject: Re: Floating point problems with 68000 (no FPU)
> Joel Sherrill wrote:
> >
> > Doug Broadwell wrote:
> > >
> > > I just started using the newlib floating point library with the
following
> > > results:
> > >
> > > sqrt(2) = 1.414213
> > > sqrt(10) = 10.000002
> > > sqrt(100) = 0.000000
> > > sqrt(10000) = 0.000000
> > >
> > > In one test sqrt(100)
> > >
= -7239...............................................................0,
> > > some 160 character long number.
> > >
> > > I'm using printf("%f", sqrt(n)) for these results.
> > >
> > > Any suggestions on how to debug?
> >
> > Did you include math.h? Not getting a proper prototype would
> > be a simple and common problem.
> >
>
> Yes. As well, make sure you have <stdio.h>.
>
> IIRC, you were manually specifying the libraries to link in.
> If it does not turn out to be as simple as a prototyping problem, you
> will want to ensure you got the correct libgcc for the float
> operations. Also try looking in gdb at the input value passed to sqrt in
hex to ensure
> it is the correct IEEE floating point double value with the endianness you
are
> expecting. This is fairly easy since you are passing integer values.
> Failing that, you might want to verify the return value of sqrt separate
> from printf - again looking at the hex return value (e.g. for sqrt(100.0)
it
> is fairly easy to confirm).
>
> -- Jeff J.
>