Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Range-aware modulo operator -% Date: Tue, 01 Jan 2019 12:48:38 -0800 Organization: None to speak of Lines: 39 Message-ID: References: <9RxWD.81420$N45.2557@fx21.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="a1e3a0589224a2dccf0492cf179df393"; logging-data="29310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+j7QFXFALiAGP4vrEvP3rJ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:VqB+4iwV6PcilKNVnkAOV9S8Ogw= sha1:5FxnrkiAe9lLYFNeTBiDWZwToMs= Xref: csiph.com comp.lang.c:139333 Bart writes: > On 01/01/2019 03:06, Keith Thompson wrote: >> Bart writes: [...] >>> Perhaps simpler might be to say that operands of if(), while(), for(;;), >>> &&, || unary !, need to be either already Bool, or have to be converted >>> to Bool. >> >> Assuming you mean _Bool, no, that's not what they do. C90 didn't >> have a boolean type. > > I deliberately didn't use _Bool. None of my languages have a boolean > type, but the compilers do have one internally, just for this purpose, > as something that should be yield by a conditional expression. So you think it's simpler to describe it in terms of a type that exists only internally in your compiler? Did you expect the rest of us to know what you meant by "Bool"? >>> It is that last that can also be done with !!. >> >> No, !!expr (for any scalar expression expr) yields a value *of type >> int*, either 0 or 1. >> >> 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. The result has type int. >> The expression !E is equivalent to (0==E). > > if X is a scalar expression, what's the difference in the value (not > type) of !!X compared with (_Bool)X? They differ in type. I never said they differ in value. -- Keith Thompson (The_Other_Keith) kst@mib.org Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"