That's what I meant, even though it wasn't what I said. I'll have to pay as
much attention to my English as I do to my programming! ;-)
Thanks,
Steve
-----Original Message-----
From: Richard M. Hartman [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 03, 2000 1:48 PM
To: Palm Developer Forum
Subject: Re: Multiplication Madness Revisited
Casting the entire multiplication would be
(long) (24 * 24 * 60)
which is not what you want, I'm sure. I -think- that when you
said "cast the entire multiplcation" you meant
(long) 24 * 24 * 60
Which is, due to precedence, equivilant to
((long) 24) * 24 * 60
but that would not really be casting the entire multiplication now,
would it? ;-)
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
McMicken, Steven wrote in message <3528@palm-dev-forum>...
>
>Read the entire thread on "Simple multiplication madness." The gist,
>however, is that you must cast at least one of the constants before
>performing the operation. Or, cast the entire multiplication since the
cast
>operator takes precedence over multiplication.
>
>Regards,
>
>Steve
>
>> -----Original Message-----
>> From: Bradly J. Barton [mailto:[EMAIL PROTECTED]]
>> Sent: Monday, February 28, 2000 9:40 PM
>> To: Palm Developer Forum
>> Subject: Multiplication Madness Revisited
>>
>>
>> (Second attempt to post, apologies if this is a repeat.)
>>
>> I didn't see any resolution to this in the last couple
>> digests, so at risk
>> of opening a raw wound, I'd like to add my two cents and a
>> piece of sample
>> code...
>>
>> I first encountered this problem when trying to code something that
>> required yesterday's date.. so I decided the best way to do
>> this was to
>> take the return value from TimGetSeconds, subtract a day's worth of
>> seconds, and feed that result to TimSecondsToDateTime.. the
>> first pass of
>> code looked like this:
>>
>> DateTimeType dateTime;
>> TimSecondsToDateTime((TimGetSeconds() - (60 * 60 * 24)), &dateTime);
>>
>> Now, peculiarly enough.. this was not giving me the right
>> answer.. so I
>> changed it a little:
>>
>> DateTimeType dateTime;
>> ULong secs = TimGetSeconds() - (60 * 60 * 24);
>> TimSecondsToDateTime(secs, &dateTime);
>>
>> And the answer still wasn't right.. so I tried this:
>>
>> DateTimeType dateTime;
>> ULong adaysworthofsecs = 60 * 60 * 24;
>> ULong secs = TimGetSeconds();
>> secs -= adaysworthofsecs;
>>
>> Ok, now I was confused.. but only for a moment.. tracing the
>> above code in
>> the debugger, I found the value assigned to adaysworthofsecs
>> was only 20864
>> (ok, I'm trying to remember off the top of my head, but it
>> was close to
>> that number). A quick check showed that the actual value
>> 86400 - 20864 was
>> 65536 ... hmmm.. curiouser and curiouser.. so deciding to do
>> it the way I
>> probably should have in the first place (and just plugged
>> 86400 in directly
>> instead of adding all of that compile time/run time depending on
>> optimization nonsense), I had the completed code:
>>
>> ULong secs;
>> ULong adaysworthofsecs = 86400; // 60 secs/min * 60 mins/hr *
>> 24 hrs/day
>> char yest[11];
>> secs = TimGetSeconds();
>> secs-= adaysworthofsecs;
>> TimSecondsToDateTime (secs, &dateTime);
>> StrPrintF(yest, "%02d/%02d/%d", dateTime.month, dateTime.day,
>> dateTime.year);
>>
>> So, bottom line.. why does the compiler do this? It assumes
>> integer values
>> for the constants even though its being assigned to a long?
>> What's up with
>> that?
>>
>> Bradly J. Barton - [EMAIL PROTECTED]
>> Jenies Technologies Incorporated
>> (972) 602-1835
>> JTI.net
>> PalmInHand.com
>>
>>
>> --
>> For information on using the Palm Developer Forums, or to
>> unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
>>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html