Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!85.12.16.69.MISMATCH!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx33.am4.POSTED!not-for-mail Subject: Re: Range-aware modulo operator -% Newsgroups: comp.lang.c,comp.lang.c++ References: <9RxWD.81420$N45.2557@fx21.am4> From: Bart User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Lines: 29 Message-ID: X-Complaints-To: http://netreport.virginmedia.com NNTP-Posting-Date: Tue, 01 Jan 2019 01:06:54 UTC Organization: virginmedia.com Date: Tue, 1 Jan 2019 01:06:47 +0000 X-Received-Bytes: 2200 X-Received-Body-CRC: 280605361 Xref: csiph.com comp.lang.c:139313 comp.lang.c++:62682 On 01/01/2019 00:44, Keith Thompson wrote: > Bart writes: > [...] >> If you write if(x), while(x), or for(;x;), then it automatically applies >> the effective equivalent of !! to give a true (x!=0) or false (x==0) >> result. (The same with (x && y) and any such combinations.) > [...] > > That's one way to describe it. It's now how the standard describes it. > > For example, the description of the "if" statement says "the first > substatement is executed if the expression compares unequal to 0", > which I find clearer and simpler than your reformulation. That's the whole expression. It doesn't really explain how a complex expression ends up as zero or not zero. Or the difference between A && B when B is 'b==x' and when B is just 'b'. From a design and implementation point of view, you have to go into it in more detail. 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. It is that last that can also be done with !!. -- bart