[geeks] Quick C question

Greg A. Woods woods at weird.com
Thu Jul 25 11:02:29 CDT 2002


[ On Thursday, July 25, 2002 at 09:02:10 (-0400), Joshua D Boyd wrote: ]
> Subject: Re: [geeks] Quick C question
>
> > > s = s * 2891336453 + 1;
> 
> That's what I thought, but it didn't.  Although, I actually used
> (unsigned long) rather than (unsigned int) (since s in an unsigned long).

I'm fairly certain that in ISO C (1989 at least) that the cast is
implicit (it would be in traditional C for sure).  That's not what the
compiler was complaining about.  It was complaining that a constant
value in that form is normally an "int" value by default and that
particular number is too big for a portable "int".  Sticking the "UL" on
the end tells the compiler that you want to start out with an "unsigned
long" value (and thus by doing so you take away the need for the
implicit cast, though that's inconsequential to this discussion).

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods at ieee.org>;           <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>



More information about the geeks mailing list