hello,

Sorry, i have ever send this message, but i need really an answer to continue my 
project.

I have some problems with float : i'd like to add and substract some =
floats, i use Code Warrior 6 and when i write a float function like =
"FplAdd", this one is written in higtlight and the compiler refuse it.
when i use what i found in the archives :

RectangleType theRect;
FlpCompDouble theCompFloat;
char theString[80];
float theFloat;

// Convert a string to a float
theCompFloat.fd =3D FlpAToF( "12345.678" );
theFloat = theCompFloat.d;

// Convert a float to a string
theCompFloat.d =1234.678;
FlpFToA( theCompFloat.fd, theString );

it runs ok.

this is my function :
static void Calcule_add (char chaine1[10], char chaine2[10])
{
        float ch1, ch2, result;
        FlpCompDouble theCompFloat, theCompFloat2, theCompFloat3;
        char addition[10];
        char* charPtr;


        // Convert a string to a float
        theCompFloat.fd = FlpAToF( chaine1 );
        theCompFloat2.fd = FlpAToF( chaine2);
        ch1 = theCompFloat.d;
        ch2 = theCompFloat2.d;
        result = (ch1 + ch2)*10;
        theCompFloat3.d = result;
    FlpFToA(theCompFloat3.fd, addition);
    charPtr = StrChr(addition, '.');
    FrmCustomAlert(DebugAlert, "test",addition, charPtr);
 } 

i tested it with these strings :

   char cha1[10] = {'1','5','.','5','4','\0'};
   char cha2[10] = {'4','.','8','5','\0'};

when i add these two floats, this result is given to me : 2.0389999e01
the result is correct, but i'd like to obtain another format, like =
"20.39".

how can i add or substract floats ?

thank you.




--
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