[geeks] Quick C question
Joshua D Boyd
jdboyd at cs.millersville.edu
Thu Jul 25 09:26:28 CDT 2002
On Thu, Jul 25, 2002 at 10:22:19AM -0400, Dave McGuire wrote:
> It didn't? Hmm, that's weird. It's my understanding that it should
> have.
Using a seperate test program, here is an exact program, and the
error:
jdboyd at cs ~ 48 > cat test.c
void main () {
unsigned long s;
s = 0;
s = s * (unsigned int)2891336453 + 1;
}
jdboyd at cs ~ 49 > g++ test.c
test.c: In function `int main(...)':
test.c:4: warning: decimal integer constant is so large that it is
unsigned
jdboyd at cs ~ 50 >
Changeing from unsigned int to unsigned long, ala:
s = s * (unsigned long)2891336453 + 1;
does change the warning.
Now, if I change that to:
jdboyd at cs ~ 48 > cat test.c
void main () {
unsigned long s;
s = 0;
s = s * 2891336453UL + 1;
}
jdboyd at cs ~ 49 >
then we are good to go.
--
Joshua D. Boyd
More information about the geeks
mailing list