Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What is the value after operator '!'? |
| Date | 2015-10-26 13:42 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87k2q9lp98.fsf@bsb.me.uk> (permalink) |
| References | <7229ebda-7352-441e-9946-ccee1ce81b03@googlegroups.com> |
fl <rxjwg98@gmail.com> writes: > Hi, > > I saw coding such as: a=!a before. Today, when I write my code below, I find > if on_off_flag==0, on_off_flag will be '1' after > > on_off_flag = !on_off_flag; > > It is a surprise to me. I supposed it will be 0xFFFF,FFFF for integer > on_off_flag You want ~ for that though, technically, the result is not 0xFFFFFFFF. That's a very large positive number and the result of ~0 is (on most systems) -1. > '!' is an inverse operator or not? From the C standard: "The result of the logical negation operator ! is 0 if the value of its operand compares unequal to 0, 1 if the value of its operand compares equal to 0." <snip> -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is the value after operator '!'? fl <rxjwg98@gmail.com> - 2015-10-26 06:21 -0700
Re: What is the value after operator '!'? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-26 09:29 -0400
Re: What is the value after operator '!'? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-26 13:42 +0000
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 07:53 -0700
Re: What is the value after operator '!'? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-26 17:37 +0000
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 11:05 -0700
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 11:38 -0700
Re: What is the value after operator '!'? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-10-26 20:27 +0000
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 14:16 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 17:15 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 17:12 -0700
Re: What is the value after operator '!'? Ian Collins <ian-news@hotmail.com> - 2015-10-27 10:27 +1300
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-26 15:15 -0700
Re: What is the value after operator '!'? supercat@casperkitty.com - 2015-10-26 16:16 -0700
Re: What is the value after operator '!'? Keith Thompson <kst-u@mib.org> - 2015-10-27 08:39 -0700
Re: What is the value after operator '!'? Richard Heathfield <rjh@cpax.org.uk> - 2015-10-26 14:04 +0000
Re: What is the value after operator '!'? Geoff <geoff@invalid.invalid> - 2015-10-26 09:50 -0700
csiph-web