Right.  I think the key item is that if you need to use the floating point
functions which require FlpDouble type values, and also need to do
operations that require double type operands, you should use variables of
the FlpCompDouble type.  This type (union) gives both double and FlpDouble
views to a value, so that
with variable declarations:
FlpCompDouble myvalue, anothervalue;
Char *s;
int err;

the following lines look at myvalue as a double and then as a FlpDouble:
myvalue.d = anothervalue.d * 50.0;
err = FlpFToA(myvalue.fd,s);


hth
/js

In your message regarding Re: Multiplication Operation. dated Fri, 7 Oct
2005 08:11:39 -0500, Katie A. (Moor) Siek said that ...

>  Here is a code snippet I used to take two numbers from fields, multiply 
>  them, and put them in another field.
>  
>       char ProductString[50];
>       char *Field1 = "0.00000000";
>       char *Field2 = "0.00000000";
>       FormPtr frm;
>       double a, b, sum;
>       FlpCompDouble aF, bF;
>       FieldType *Field;
>       Int16 TappedButton;
>  
>       // Read and add floating point
>       // get field string
>       frm = FrmGetActiveForm();
>       Field = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, MainFluidField));
>       
>       //Is the field empty?
>       if (FldGetTextLength(Field) == 0){
>               TappedButton =
>                       FrmCustomAlert(MoreInfoAlert, "First #", NULL, NULL);
>       }
>       else { // Field is not empty, convert string to fp
>               Field1 = FldGetTextPtr(FrmGetObjectPtr(frm,
>                       FrmGetObjectIndex(frm, MainFluidField)));
>               aF.fd = FlpAToF(Field1);
>               a = aF.d;
>       }
>  
>       // check the second field
>       Field = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, MainSodiumField));
>       
>       if (FldGetTextLength(Field) == 0){
>               TappedButton =
>                       FrmCustomAlert(MoreInfoAlert, "Second #", NULL, NULL);
>       } else{
>               Field2 = FldGetTextPtr(FrmGetObjectPtr(frm,
>                       FrmGetObjectIndex(frm, MainSodiumField)));
>               bF.fd = FlpAToF(Field2);
>               b = bF.d;
>       }
>  
>       product = a * b;
>  
>       // This is a function that was posted on the mailing list recently
>       GetStringFromDouble(ProductString, product, 8);
>               
>       // print it to the result field
>       StrPrintF(PrintString, "%s \n %s \n %s \n",
>                               Field1, Field2, ProductString);
>       SetFieldText(MainResultField,PrintString);
>  
>  
>  On Oct 7, 2005, at 6:40 AM, Dighe Jeetendra wrote:
>  
> > i tried to use double but i have some problems while saving & 
> > displaying float values.
> >
> > On 10/7/05, Ben Combee <[EMAIL PROTECTED]> wrote: At 03:07 AM 
> > 10/7/2005, you wrote:
> >> >Hello EB,
> >> >       I have a problem in doing multiplication of
> >> >float values,I have taken some variables of type
> >> >UInt32 & FlpDouble for storing Long & Float values.
> >> >
> >> >         Based on above datatypes & variables , I want to
> >> >perform arithmetic operations like:-
> >> >
> >> >         FlpDouble a,b,c;
> >> >         a= (any constant value) * b;
> >> >         a= b*c;
> >> >
> >> >         I get an error msg at compile time "Invalid operands
> >> >to binary * "
> >>  >
> >> >         Are there any functions which support basic
> >> >arithmetic operations related to Multiplication
> >> >
> >> >        Sample code snippet would really help..
> >>
> >> You need to use the right type.  Just use double, not FlpDouble.
> >>
> >>
> >> -- Ben Combee, Senior Software Engineer, Palm, Inc.
> >>    "Combee on Palm OS" weblog: http://palmos.combee.net/
> >>    Developer Forum Archives:   http://news.palmos.com/read/all_forums/
> >>
> >>
> >> --
> >> For information on using the PalmSource Developer Forums, or to 
> >> unsubscribe, please see http://www.palmos.com/dev/support/forums/
> >
> >  -- For information on using the PalmSource Developer Forums, or to 
> > unsubscribe, please see http://www.palmos.com/dev/support/forums/
>  *~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*
>  Katie A. (Moor) Siek
>  PhD Candidate                                (812) 856-2107
>  Indiana University                           [EMAIL PROTECTED]
>  Computer Science Department         http://www.cs.indiana.edu/~ksiek
>  *~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*
>  
>  -- 
>  For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/



-- 

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

Reply via email to