followup to Re: unbelievable "simple" question/bug?
Jim Klavetter
jjk at jupiter.astro.umd.edu
Fri Mar 29 09:19:24 AEST 1991
>
>Are you sure they are all ints? If one of either a or b or c is really
>an UNSIGNED int, then a-b-c would be some big positive number, which
>would explain the first example. If temp is an int, then putting that
>big positive integer back in temp would do what you want, since temp
>would then have the value -1.
>==================
>Chris Volpe
Thanks to Chris and the others who e-mailed me, this was indeed the
case. I took the original expression and added a cast to make all
types "int" and it worked as expected. According to PROGRAMMING IN
ANSI C by Kochan, there are 6 rules for data type conversions.
Unfortunately, nowhere in those rules does the question of int vs
unsigned (int) enter. Upon reflection, I think this is a mistake, or
at least shortcoming, of this text. Does K&R2 explicitely mention
this?
Also, can someone post or send the full set of conversion rules? I
would like to know exactly what I was comparing. Thanks again.
jjk at astro.umd.edu also for Athabasca and Reudi
Jim Klavetter
Astronomy
UMD
College Park, MD 20742
More information about the Comp.lang.c
mailing list