Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #142880

Re: Application Exercises

From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c
Subject Re: Application Exercises
Date 2019-04-06 23:52 -0700
Organization A noiseless patient Spider
Message-ID <865zrqmhmq.fsf@mailhub.linuxsc.com> (permalink)
References <exercise-20190406184435@ram.dialup.fu-berlin.de> <5ca8ee5c$0$21621$426a34cc@news.free.fr> <padding-20190406192459@ram.dialup.fu-berlin.de>

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Mateusz Viste <mateusz@wont.tell> writes:
>
>> On Sat, 06 Apr 2019 18:01:32 +0000, Stefan Ram wrote:
>>
>>> |Write a function to detect whether two integral numbers are |equal
>>> without using any comparison operators.
>>> . As a hint he wrote:  "Think of bit operators.".
>>
>> /* returns 0 if a == b, non-zero otherwise */
>> int isnotequal(int a, int b) {
>>  return(a ^ b);
>> }
>
>   Yeah, but what about padding bits (N2310, 6.2.6.2p5)?

Padding bits do not participate in the computation of
the &, ^, and | operators.  Unless the result is a trap
representation corresponding to a negative zero, or
the (trap) distinguished representation for two's
complement, these operators work as expected and always
produce valid values.

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: Application Exercises Mateusz Viste <mateusz@wont.tell> - 2019-04-06 18:22 +0000
  Re: Application Exercises donalhambra@gmail.com - 2019-04-06 12:07 -0700
  Re: Application Exercises Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-04-06 23:52 -0700

csiph-web