On Fri, 25 Feb 2000 13:52:58 +0100 (MET) [EMAIL PROTECTED] wrote:

> Thanks! In which file/header or whatever are such rules defined? I'd like

> to print it out in order to prevent such errors.

> 

> I've even tried

>  NumOfDays=(T2-T1)/(ULong)(24*3600)+1;

> but with the same (wrong) result. It seems that for a*b compiler takes



No then you should do:



 NumOfDays=(T2-T1)/((ULong)24*(ULong)3600)+1;



because with the way you have it, by the time you cast it to ULong, the value has 
already been truncated to 16-bits.





> sizeof(a), then sizeof(b) and result is truncated to

> Max{sizeof(a),sizeof(b)}.

> Is it matter of compiler or PalmOS or C in general?

> 

> Rgds,

> 

> -DR

> 

> 

> On Fri, 25 Feb 2000, Al Cilcius wrote:

> 

> > The type of the result of (24 * 3600) is int.  On PalmOS this is 16bits in

> > size. The result can not fit in 16bits so the high-order bits are

> truncated > leaving you with the lower 16bits which are 0x5180 ==

> 20864decimal. >

> > -----Original Message-----

> > From: [EMAIL PROTECTED]

> > [mailto:[EMAIL PROTECTED]]On Behalf Of Danko Radic

> > Sent: Friday, February 25, 2000 3:52 AM

> > To: Palm Developer Forum

> > Subject: Little C or compiler question

> >

> >

> > (CW R5 + 2 patches, Win95)

> >

> > I have:

> >

> >  ULong      T1,T2,NumOfDays;

> >

> > Why does:

> >

> >  NumOfDays=(T2-T1)/86400+1;

> >

> > give correct result and

> >

> >  NumOfDays=(T2-T1)/(24*3600)+1;

> >

> > doesn't?

> > T1, T2 are times in seconds, and when they differ for 1.999 days, 1st

> > operation gives correct NumOfDays=2, but 2nd gives result NumOfDays=9.

> > If it is automatic casting problem, where can I find these rules?

> >

> > Rgds,

> >

> > -DR

> >

> >

> > --

> > 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







This message sent using EMUmail.  http://EmuMail.com

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

Reply via email to