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


Groups > comp.lang.c > #401692

Re: why &| dont work and its possible to make it work

From fir <profesor.fir@gmail.com>
Newsgroups comp.lang.c
Subject Re: why &| dont work and its possible to make it work
Date 2026-09-07 18:14 +0200
Organization A noiseless patient Spider
Message-ID <117mnso$3dn0r$1@dont-email.me> (permalink)
References <117mere$3a14a$1@dont-email.me> <117mm0k$3cu2d$1@dont-email.me>

Show all headers | View raw


bart pisze:
> On 07/09/2026 14:39, fir wrote:
>> as i once said i decided to not use && and || as it annoys me (same s 
>> == annoys me)
>>
>> so i will decide to use & | insted but as i not code regullarry today 
>> i not yet maneged to test it throughly when it not work and
>> if it need big changes in languege to work
>>
>> i mean one option is that & | should work for BOTH logical and bitwise
>>
>> is it possible?
> 
> No, because they do different things. But if you can only have one, then 
> & and | are  more flexible:
> 
> I think 'A && B' is equivalent to  '(!!A ? 1 : (!!B ? 1 : 0))', if a 
> boolean result is needed.
> 
> You can't do '!!A & !!B' because && short-circuits.
> 
> 
> 
> 
>>
>> if not i wuld probably suggest using some other methods to make it 
>> work (i could eventually say that &| would better work for logical and 
>> && || for bitwise but im not saing this becouse it would alos be bad imo)
>> so maybe better it should work for both (?)
>>
>> if it not brings some problems i suspect something like
>>
>> 3&4 has different meaning in logical (1) and bitwise (7) but is that a 
>> problem?
> 
> Yeah, it's a problem: 3&4 has result 0, but 3&&4 has result 1. But in 
> this case, (!!3)&(!!4) can be used to give 1.
> 
> 

lol i misluked it - i thought 3&4 is 7

its kinda confusing

3&4 is logically true, so bitewise also should be true here t work, i guess

3|4 is logically also true , so bitewise it also should be true ?

to make it work?

"logical" operators and and or are for sure defined well in thsi sense
tahat A & B & C should be tru if all are true. otherwise false,
A|B|C should be true if only one or more is true.. though natural 
reading here is confusing becouse for me as i said 3&4 for me "reads"as 
7 (3|4 also "reads" as 7 probably)

it seems that those mathematical signs u and close to n (reversed u) 
could fir better 3u4 = 7 3n4 = 0

SO

it seems that indeed & and | would not work becouse

A & 3 & 4 & B when A and B are true should give true
(and i assume A and B would be presented as 1 so result is 0)

A |3 |4 |B will give 7  - so in this case its ok, so it seems | work but 
& fails

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


Thread

why &| dont work and its possible to make it work fir <profesor.fir@gmail.com> - 2026-09-07 15:39 +0200
  Re: why &| dont work and its possible to make it work bart <bc@freeuk.com> - 2026-09-07 16:42 +0100
    Re: why &| dont work and its possible to make it work fir <profesor.fir@gmail.com> - 2026-09-07 18:14 +0200
    Re: why &| dont work and its possible to make it work Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-09 07:14 +0000
      Re: why &| dont work and its possible to make it work Bonita Montero <Bonita.Montero@gmail.com> - 2026-09-09 11:15 +0200
      Re: why &| dont work and its possible to make it work bart <bc@freeuk.com> - 2026-09-09 11:23 +0100
        Re: why &| dont work and its possible to make it work fir <profesor.fir@gmail.com> - 2026-09-09 13:28 +0200
          Re: why &| dont work and its possible to make it work fir <profesor.fir@gmail.com> - 2026-09-09 14:01 +0200
  Re: why &| dont work and its possible to make it work Bonita Montero <Bonita.Montero@gmail.com> - 2026-09-07 17:49 +0200
    Re: why &| dont work and its possible to make it work fir <profesor.fir@gmail.com> - 2026-09-07 18:22 +0200
    Re: why &| dont work and its possible to make it work Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-09-09 06:07 +0000
  Re: why &| dont work and its possible to make it work Kaz Kylheku <046-301-5902@kylheku.com> - 2026-09-10 20:13 +0000

csiph-web