Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: maximum value of int |
| Date | 2011-09-17 17:25 +1200 |
| Message-ID | <9dipadFr5dU3@mid.individual.net> (permalink) |
| References | <394fc242-c6ae-41ba-9861-6d4c88ec25b5@f17g2000yqh.googlegroups.com> |
On 09/17/11 05:07 PM, Stanley Rice wrote: > Hello all > > I don't know it is appropriate to post such a short or easy question > here. I couldn't understand some line of code abot maximum int value > as below: > > #define INT_MAX (((unsigned)-1)>> 1) > > The first time I saw it, I was confused why it could pass the > examination of the compiler. I try to make a bit modification, say > #define INT_TEST ((unsigned) - 1) > This time, the compiler also shuts its mouth, but when I try > #define INT_TEST (unsigned) > The compiler begins to shout to me. > > I'm confused about why the type itself, i.e unsigned, could do > subtration. And it could generate an integer. But when I leave the > type alone, the compiler tries to stop me. (unsigned)-1 is a cast, not a subtraction. -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
maximum value of int Stanley Rice <heconghui@gmail.com> - 2011-09-16 22:07 -0700
Re: maximum value of int Ian Collins <ian-news@hotmail.com> - 2011-09-17 17:25 +1200
Re: maximum value of int Stanley Rice <heconghui@gmail.com> - 2011-09-17 00:47 -0700
Re: maximum value of int Paul N <gw7rib@aol.com> - 2011-09-17 03:53 -0700
Re: maximum value of int Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-17 12:17 +0100
Re: maximum value of int Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-09-17 10:31 -0600
Re: maximum value of int Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-17 19:51 +0100
Re: maximum value of int Keith Thompson <kst-u@mib.org> - 2011-09-17 14:39 -0700
Re: maximum value of int Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-17 07:51 -0400
csiph-web