I like to use macros to make the code easier to read. But it always a good
idea to cast when performing mixed type operations.
#define F(x) ((float)(x))
int imyInt;
float fmyFloat;
float fmyAnswer;
fmyAnswer = F(imyInt) * fmyFloat;
----- Original Message -----
From: Steve Mann <[EMAIL PROTECTED]>
To: Palm Developer Forum <[EMAIL PROTECTED]>
Sent: Saturday, July 28, 2001 12:20 PM
Subject: Re: Multiplying Ints and Floats
> >I have an equation, and I need to multiply an Int16 by a float, with the
> >answer also being a float. However, the answer seems to come out to
zero.
> >My only guess is that it doesn't like multiplying the Int and the float.
>
> It might help to explicitly cast the int to a float before
> multiplying. Also, break the equation out into a series of smaller
> intermediate steps and check the results.
>
> Regards,
> Steve Mann
> --
> Creative Digital Publishing Inc.
> 1315 Palm Street, San Luis Obispo, CA 93401-3117
> -------------------------------------------
> 805.784.9461 805.784.9462 (fax)
> [EMAIL PROTECTED] http://www.cdpubs.com
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/