Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Dec 2008 10:59:54 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        "Garrett Cooper" <yanefbsd@gmail.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, Christoph Mallon <christoph.mallon@gmx.de>, Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
Subject:   Re: RFC: small syscons and kbd patch
Message-ID:  <861vwnhrhh.fsf@ds4.des.no>
In-Reply-To: <7d6fde3d0812050131p2e9ac761n1c76575d3a3f5792@mail.gmail.com> (Garrett Cooper's message of "Fri, 5 Dec 2008 01:31:12 -0800")
References:  <bb4a86c70812021701i621fdcfjb6a58a7f5cf781d5@mail.gmail.com> <7d6fde3d0812040324y3bf0901cy1f4a6d961362c314@mail.gmail.com> <bb4a86c70812040724w43ddec15yab72920d80d879d3@mail.gmail.com> <20081205072229.GE18652@hoeg.nl> <7d6fde3d0812050034y43a70ce8i49fbba92f9c8943b@mail.gmail.com> <7d6fde3d0812050035u6e3ea930o9e093830a8608444@mail.gmail.com> <20081205084441.GA29312@owl.midgard.homeip.net> <7d6fde3d0812050050l57684eebkf14f252d78b68ec0@mail.gmail.com> <4938F036.4010600@gmx.de> <7d6fde3d0812050131p2e9ac761n1c76575d3a3f5792@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
"Garrett Cooper" <yanefbsd@gmail.com> writes:
> If you really want to split hairs, ! only negates the logic value,
> whereas ~ actually negates the bits. So technically, you're not
> flipping 0 to make 1 and vice versa, but instead flipping 0 to make
> non-zero, etc. There is a clear distinction in hardware.

He didn't say anything about flipping bits...  and you're wrong, !0 is
guaranteed to evaluate to 1.

> The point was that !! isn't obvious at first glancing the C code.

It is to an experienced C programmer.

> Getting down to it I'd like to see what the compiler optimizes each
> as, because I can see dumb compilers saying `!!'  translates to `not,
> bne =3D> set, else set, continue', whereas `? :' could be translated to
> `bne, set, else set, continue'; I'm sure gcc has moved passed these
> really minute details.

Never try to second-guess the compiler.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?861vwnhrhh.fsf>