I am trying to get a floating point number to display in a field with two decimal places.
The code below gets a number entered by a user and adds it to a total. The total is subsequently displayed. It works OK but the answer gets displayed as x.yyyyyyyye, instead of x.yy. As an example, if the user enters the numbers 100.50 and 200.25, the answer is displayed as 3.0075000e instead of 300.75. I have not been able to find any routines that provide the decimal alignment that I want and I can't find the definition of FlpDouble which, I am sure, is a structure typedef. Thanks //* // global definitions //* FlpDouble tempTotal; char * tempchar; //* //extract the value entered by the user and add to total //* char * ptr; tempchar = GetTextFromField(ExpensesAmountField); //If user did not enter decimal data then add .00 to the end of the string ptr = StrStr(tempchar, "."); if (ptr == NULL) StrCat(tempchar, ".00"); tempTotal = FlpCorrectedAdd(tempTotal,FlpAToF(tempchar),0); //* // Convert a float to a string //* char * charTotal; MemHandle h; FieldPtr totalFP; h = MemHandleNew (60); charTotal = MemHandleLock (h); FlpFToA(tempTotal, charTotal); totalFP = GetObjectPtr (ExpenseListTotalExpenseField); FldSetTextHandle ( totalFP,h); Ed Van Vliet Alliance Technical Services Palm Inc. Tel. 919 847 7915 Mobile 919 522 5141 -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
