On Mon, Oct 22, 2001 at 04:21:40PM +0200, Chalain Marc wrote:
> Can you give me some observations on this code, please?
> 
> extern double DoubleIToD( int i) SECT_UI2;

So you want a function to convert from int to double?  Why make life so
difficult when you can simply write it like this:

        double DoubleIToD (int i) { return i; }

> double
> DoubleIToD( int i)
> {
>     FlpCompDouble x;
>     char buffer[32];
> 
> //that, it works fine
>     StrIToA(buffer, i);

But for the sake of argument, let's imagine that _buffer_ is the input,
and you really do need to do a text to float conversion.

> #ifdef USE_OPERATORS_AND_BUFFERED_FUNCTIONS
>     FlpBufferAToF( &x.fd, buffer);
> #else
>     x.fd = FlpAToF(buffer);
> #endif

I am glad you have read the commentary in FloatMgr.h, and found the sample
code in the SampleCalc SDK example.  However, you should probably note the
discussion of USE_OPERATORS_AND_BUFFERED_FUNCTIONS in SampleCalc.c, which
says "We want to demonstrate both, so need to go to more trouble than a
real application would".  You compile your application solely with GCC, so
you don't need or want to demonstrate all the alternatives, as we did in
the sample.

So here you need to decide which of FlpAToF and FlpBufferAToF you need
to use.  You have told me privately that you have read this note in
FloatMgr.h:

        programs compiled with GCC using the standard functions [FlpAToF,
        FlpCorrectedAdd, FlpCorrectedSub] above are likely to crash: GCC
        users must use the FlpBuffer* forms of these functions.

If this note is unclear, please suggest a way in which it could be
clarified.  

> I use GCC and prc-tools 2.0.9x.
> I work on that for 2 days without solution.
> Should i add -lnfm in the compilation lines?

When you searched the archives before asking this question (and you did
search the archives, right?), I'm sure you came across this posting
which I believe answers this question:

        http://www.escribe.com/computing/pcpqa/m35274.html

> is _d_itod reconized by GCC?

FloatMgr.h goes on to say "Many of the _d_* functions further below
suffer from the same problem [namely causing GCC-compiled apps to
crash]".  If this and the rest of that comment do not answer this
question, please suggest a way in which the comment could be clarified.

> Which system trap, i must use?

I think this is mostly answered in the URL referenced above too: mostly
you don't want to do anything so low level as calling fp systraps directly.

The general observation here is that for two days you have had all the
components of a working piece of code here.  To get it to work, all you
need to do is *experiment*.  You don't need to ask us whether to use
-lnfm or which or any of FlpBufferAToF, FlpAToF, or _d_itod to use: you
can just try the different alternatives, and see what works and what the
effects are.  This is a great way to learn and to understand what's going
on.

    John

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to