Bradly J. Barton <[EMAIL PROTECTED]> wrote:
> DateTimeType dateTime;
> ULong adaysworthofsex = 60 * 60 * 24;
Gee, it's almost as if this is equivalent to
UInt fred = 60 * 60 * 24;
ULong adaysworthofsex = fred; /* Blast! fred only has 16 bits! */
...which, in fact, it is (if you replace UInt by plain old int).
Please, before we have to get into this again, go and read some of the
references at
http://www.eskimo.com/~scs/C-faq/q3.14.html
> So, bottom line.. why does the compiler do this?
Because that's the way the language works.
> It assumes integer values
> for the constants even though its being assigned to a long? What's up with
> that?
It hasn't seen the long yet. (Okay, it saw the long's name while it was
parsing, but it hasn't noticed its type yet.) Try to look at it somewhat
like what the compiler does, which is from the inside out:
60 oh, an int
60 another int
60 * 60 ok, int * int -> int
temp60x60 int
24 another int
temp60x60 * 24 ok, int * int -> int
temp60x60x24 int
aday hmmm an unsigned long lvalue
aday = temp60x60x24 ok, assign an int to an unsigned long, so
we'll have to do a conversion now
If you're still confused after reading K&R and/or H&S, you might want to
go ask the C experts over at comp.lang.c.moderated, where they're better
equipped to answer your question than we Palm OS folks are. Of course,
since you're asking one of the easier FAQs, they might equip themselves
with flamethrowers... :-)
John "modulo whichever of left/right associativity it is"
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html