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


Groups > comp.lang.c > #154740

Re: Bit Swizzling

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Bit Swizzling
Date 2020-09-08 13:06 -0700
Organization None to speak of
Message-ID <87y2lkjaol.fsf@nosuchdomain.example.com> (permalink)
References (13 earlier) <rj8fce$ppd$1@dont-email.me> <_JCdnbMFysvEWcrCnZ2dnUU7-I_NnZ2d@giganews.com> <rj8gfn$32o$2@dont-email.me> <es2dnfpheKRAVcrCnZ2dnUU7-IfNnZ2d@giganews.com> <20200908114117.208@kylheku.com>

Show all headers | View raw


Kaz Kylheku <793-849-0957@kylheku.com> writes:
[...]
> By and large, languages broadly agree on only the "BEDMAS" precedence
> rules everyone learns in elementary school.  For other operators that
> language designers have invented, there is a large variance in
> precedences and other details.
>
> (Not all languages, have BEDMAS, either. Smalltalk is an example of a
> language in which operators are reduced left to right, because they are
> just method application, or something like that: x + y * z  means (x +
> y) * x).

And I think APL groups right-to-left (though that's probably an
oversimplification).

Note that BEDMAS doesn't entirely cover even the obvious set of
precedence rules in C.  The "E" is exponentiation, and C doesn't have
an exponentation operator.  It also omits assignment (C's treatment
of assignment as an operator can be surprising to newcomers).
The parentheses in

    x = (y + z);

are definitely superfluous.

It might be interesting to collect a list of *which* of C's operator
precedence rules are obvious enough that parentheses don't add clarity.
But it would be impossible to reach universal agreement on any such
list, and clarity depends on context.  For example, sometimes I might
consider

    a || b && c

to be clear enough, but I'd *probably* add parentheses.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

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


Thread

Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@nospicedham.gmail.com> - 2020-09-04 20:33 -0400
  Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-05 12:36 +0100
    Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-05 15:30 +0100
      Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-05 11:29 -0400
        Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-05 20:28 +0100
    Re: Bit Swizzling kegs@provalid.com (Kent Dickey) - 2020-09-05 11:35 -0500
  Re: Bit Swizzling Bart <bc@nospicedham.freeuk.com> - 2020-09-05 12:33 +0100
  Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-05 20:55 +0200
    Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-05 15:18 -0400
      Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-06 10:17 +0200
        Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-07 07:06 +0000
          Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-07 10:35 +0200
            Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-07 11:01 -0400
              Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-07 20:07 +0200
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-07 14:19 -0400
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-07 20:39 +0200
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-07 15:13 -0400
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 12:21 +0200
                Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-08 12:51 +0100
                Re: Bit Swizzling Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-09-08 05:18 -0700
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 15:20 +0200
                Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 15:56 +0000
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-08 12:17 -0400
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:31 +0200
                Re: Bit Swizzling olcott <NoOne@NoWhere.com> - 2020-09-08 12:46 -0500
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:53 +0200
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-08 15:13 -0400
                Re: Bit Swizzling (c++ versus c) olcott <NoOne@NoWhere.com> - 2020-09-08 14:59 -0500
                Re: Bit Swizzling (c++ versus c) "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-08 21:45 -0400
                Re: Bit Swizzling (c++ versus c) olcott <NoOne@NoWhere.com> - 2020-09-08 20:56 -0500
                Re: Bit Swizzling (c++ versus c) "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-09-08 19:49 -0700
                Re: Bit Swizzling (c++ versus c) Juha Nieminen <nospam@thanks.invalid> - 2020-09-09 06:27 +0000
                Re: Bit Swizzling (c++ versus c) Melzzzzz <Melzzzzz@zzzzz.com> - 2020-09-09 06:38 +0000
                Re: Bit Swizzling (c++ versus c) David Brown <david.brown@hesbynett.no> - 2020-09-09 11:54 +0200
                Re: Bit Swizzling (c++ versus c) olcott <NoOne@NoWhere.com> - 2020-09-09 09:21 -0500
                Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 16:31 +0000
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:35 +0200
                Re: Bit Swizzling olcott <NoOne@NoWhere.com> - 2020-09-08 12:50 -0500
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:53 +0200
                Re: Bit Swizzling olcott <NoOne@NoWhere.com> - 2020-09-08 13:09 -0500
                Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 18:48 +0000
                Re: Bit Swizzling + [HP] olcott <NoOne@NoWhere.com> - 2020-09-08 14:09 -0500
                Re: Bit Swizzling + [HP] Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-09-08 12:37 -0700
                Re: Bit Swizzling + [x86utm] olcott <NoOne@NoWhere.com> - 2020-09-08 16:59 -0500
                Re: Bit Swizzling + [HP] olcott <NoOne@NoWhere.com> - 2020-09-08 18:13 -0500
                Re: Bit Swizzling + [HP] olcott <NoOne@NoWhere.com> - 2020-09-08 20:07 -0500
                Re: Bit Swizzling + (HP refutation criteria) olcott <NoOne@NoWhere.com> - 2020-09-09 20:10 -0500
                Re: Bit Swizzling + [HP] olcott <NoOne@NoWhere.com> - 2020-09-09 21:07 -0500
                Re: Bit Swizzling + [HP refutation criteria] olcott <NoOne@NoWhere.com> - 2020-09-09 21:30 -0500
                Re: Bit Swizzling + [HP refutation criteria] olcott <NoOne@NoWhere.com> - 2020-09-09 21:39 -0500
                Re: Bit Swizzling + [HP] olcott <NoOne@NoWhere.com> - 2020-09-10 22:48 -0500
                Re: Bit Swizzling Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-08 13:06 -0700
                Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-08 19:37 +0100
                Re: Bit Swizzling David Brown <david.brown@hesbynett.no> - 2020-09-09 12:04 +0200
                Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 18:39 +0000
                Re: Bit Swizzling Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-09-08 12:27 -0700
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-07 15:47 -0400
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 12:23 +0200
            Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 00:07 +0000
              Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 12:26 +0200
                Re: Bit Swizzling scott@slp53.sl.home (Scott Lurndal) - 2020-09-08 15:50 +0000
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:06 +0200
                Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2020-09-08 13:13 -0400
                Re: Bit Swizzling olcott <NoOne@NoWhere.com> - 2020-09-08 12:18 -0500
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 19:28 +0200
                Re: Bit Swizzling Bart <bc@freeuk.com> - 2020-09-08 18:51 +0100
                Re: Bit Swizzling olcott <NoOne@NoWhere.com> - 2020-09-08 13:02 -0500
                Re: Bit Swizzling Bonita Montero <Bonita.Montero@gmail.com> - 2020-09-08 20:45 +0200
                Re: Bit Swizzling Kaz Kylheku <793-849-0957@kylheku.com> - 2020-09-08 15:55 +0000
  Re: Bit Swizzling olcott <NoOne@nospicedham.NoWhere.com> - 2020-09-08 11:25 -0500
    Re: Bit Swizzling olcott <NoOne@nospicedham.NoWhere.com> - 2020-09-08 11:50 -0500
    Re: Bit Swizzling Kaz Kylheku <793-849-0957@nospicedham.kylheku.com> - 2020-09-08 17:47 +0000
  Re: Bit Swizzling "R.Wieser" <address@nospicedham.not.available> - 2020-09-08 20:26 +0200
    Re: Bit Swizzling David Brown <david.brown@nospicedham.hesbynett.no> - 2020-09-08 22:00 +0200
    Re: Bit Swizzling "Rick C. Hodgin" <rick.c.hodgin@nospicedham.gmail.com> - 2020-09-08 21:51 -0400
      Re: Bit Swizzling "R.Wieser" <address@nospicedham.not.available> - 2020-09-09 10:53 +0200

csiph-web