>                       result = 10 * 3600; // Here I get -29536 instead of 36000 when 
>     
>                                            // setting a breakpoint in the 
>                                            // line below
>                                            // or 4294937760 if I declare 
>                                            // result as ULong

As other people have implied, your problem stems from the calculation not
being performed as longs, however this:

result = (Long) 10 * 3600;

or

result = (UInt32) 10 * 3600;

is not really the best way of solving the problem, mainly because it could
be seen as ambiguous (This statement ignores C's binding/evaluation rules)

I'll explain.  Whats happening is the compiler is using "short integer"
multiplication, because both static values are small enough to fit into
ints.  The result of such a multiplication really is -29535 (as a "short
int").  Once the result is calculated it is stored in your variable.  It is
the _storing_ process that converts the result into a "long int".  What you
need to do is to get a "long int" into the calculation, and while both
answers given above do this they are a little ambiguous, as they could be
taken as either of the following:

result = (Long)(10 * 3600);
result = ((Long)10) * 3600;

The "most correct" way of doing what you want is:

result = 10L * 3600L;

(You only need one of the L's, because the calculation will automatically
cause the promotion of the other static value to a "long int" before the
multiplication occurs)


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to