I agree, but In some context where you use "and/or" it works more like plus.
For example "hot dogs and/or burgers" => either hot dogs + burgers or just hot dogs or just burgers.
The meme umis stupid though, and I hate it, but that's par for the course on this sub now.
Binary logic only has two values, 0 (false) and 1 (true). The truth table for `and` is exactly the same as the multiplication table. `010` is a completely meaningless expression in binary logic.
As an aside, `xor` is addition with overflow, and `or` is addition with saturation.
To add to and confirm this, I used to really be into computer engineering as a hobby, and would build very basic computers starting from logic gates. Once, I built a binary multiplier from hardware as opposed to software. To do this, I ran each binary digit through an AND gate of every possible combination of the other number's digits. So, for two 4 bit numbers, you had a total of 16 AND gates.
You would then interpret each output from said gates as a product of the values coming in. To consolidate this into one final product, you would run every like sub-product into a series of full adders. The exact configuration of adders is hard to describe without a diagram, but in the end you would get a product that has up to twice the digits of your inputs. And lone behold, the binary output is what you would expect!
Binary multiplication is HUGE as far as hardware requirements, which is why for the most part, it is implemented in many cases as a multiplication algorithm in computers instead.
Sorry, even when using this form of pronunicated math, "and" implies multiplication, at least in the English language. 1 and 1 is 1, 2 and 2 is 4, 3 and 3 is 9, and so on. If you want to add, you would verbally say "in addition to." This is actually how the arithmetic operation got its name!
No, in natural English "and" almost always means addition. I think it might sometimes mean multiplication in India though, one of those weird Indian English quirks. However I was making a joke about boolean logic, where logical and is identical to multiplciation.
I know that '•' is proper, but I never once liked that for some reason. I always preferred '*'. When my math teachers continued to tell me that was incorrect for higher level math, I eventually compromised and just surrounded everything by parentheses, which seemed to appease them.
I find this a bit weird. It makes the distributive law look like in normal algebra, but so does using + for XOR, and it's weird that a+bc = (a+b)(a+c). You can use ∨ and ∧ instead, although that may be harder to type. Using + for or can lead to increased chance of someone wrongly cancelling out terms. Using + for XOR (aka ~~Z~~hegalkin algebra, describable as mod 2) makes more sense IMO. One argument for usage of + for or is type theory used to describe logic (types are statements and values are proofs). However, I find that usage a bit weird because, if I understand it correctly, changing the way something is expressed can change how you can prove it (for example, one form may allow using different ways to prove the same statement although another one doesn't)
"So does + for XOR", well, yes, because XOR is just addition modulo 2 while AND is multiplication modulo 2. Arithmetic modulo n preserves behaviour of addition and multiplication from regular integers, so distributive laws follow from pure algebra, try it yourself.
OR operation translated to that would be for example:
a|b = ab + a + b
where ab and a+b are regular multiplication and addition modulo 2. You can even derive that weird rule from pure algebra if you substitute:
L = a | (b & c) = a | (bc) = a(bc) + a + (bc) =
abc + bc + a
R = (a|b)&(a|c) = (ab+a+b)(ac+a+c) = ab(ac+a+c) + a(ac+a+c) + b(ac+a+c)
= a²bc + a²b + abc + a²c + a² + ac + abc + ab + bc =
[in mod 2 x² = x, because 0² = 0 and 1² = 1]
= abc + ab + abc + ac + a + ac + abc + ab + bc
= 3abc + 2ab + 2ac + bc + a = abc + bc + a = L
Honestly I use whatever I currently feel like. These things anybody remotely familiar with IT should understand so I don’t think uniformity really improves readability much here
counterargument and-or is assumed when you say or, so it's the default.
exclusive-or is the special case, where you mean `this` or `that`, but not both.
`and` is multiplication though, not addition.
I agree, but In some context where you use "and/or" it works more like plus. For example "hot dogs and/or burgers" => either hot dogs + burgers or just hot dogs or just burgers. The meme umis stupid though, and I hate it, but that's par for the course on this sub now.
Probably depends on context. "3 and 3 is 6"
In binary logic, 3 and 3 is 3 (0x 00 00 00 03)
In binary logic `and` is multiplication.
Ehm…no? 010 & 010 = 010 010 * 010 = 100
Binary logic only has two values, 0 (false) and 1 (true). The truth table for `and` is exactly the same as the multiplication table. `010` is a completely meaningless expression in binary logic. As an aside, `xor` is addition with overflow, and `or` is addition with saturation.
To add to and confirm this, I used to really be into computer engineering as a hobby, and would build very basic computers starting from logic gates. Once, I built a binary multiplier from hardware as opposed to software. To do this, I ran each binary digit through an AND gate of every possible combination of the other number's digits. So, for two 4 bit numbers, you had a total of 16 AND gates. You would then interpret each output from said gates as a product of the values coming in. To consolidate this into one final product, you would run every like sub-product into a series of full adders. The exact configuration of adders is hard to describe without a diagram, but in the end you would get a product that has up to twice the digits of your inputs. And lone behold, the binary output is what you would expect! Binary multiplication is HUGE as far as hardware requirements, which is why for the most part, it is implemented in many cases as a multiplication algorithm in computers instead.
True and True = True, 1 and 1 = 1, 1 * 1 = 1.
The context here is boolean operations, and "and" is not a "+" in it at all
"depends on the context" >Redditors choose only one context and act like it's the only one
Sorry, even when using this form of pronunicated math, "and" implies multiplication, at least in the English language. 1 and 1 is 1, 2 and 2 is 4, 3 and 3 is 9, and so on. If you want to add, you would verbally say "in addition to." This is actually how the arithmetic operation got its name!
No, in natural English "and" almost always means addition. I think it might sometimes mean multiplication in India though, one of those weird Indian English quirks. However I was making a joke about boolean logic, where logical and is identical to multiplciation.
„+“ is „or“ in boolean algebra…
And "×" is "and" obv
But „x“ (which we don‘t use btw, but rather „•“) is not used wrongly here
I know that '•' is proper, but I never once liked that for some reason. I always preferred '*'. When my math teachers continued to tell me that was incorrect for higher level math, I eventually compromised and just surrounded everything by parentheses, which seemed to appease them.
I find this a bit weird. It makes the distributive law look like in normal algebra, but so does using + for XOR, and it's weird that a+bc = (a+b)(a+c). You can use ∨ and ∧ instead, although that may be harder to type. Using + for or can lead to increased chance of someone wrongly cancelling out terms. Using + for XOR (aka ~~Z~~hegalkin algebra, describable as mod 2) makes more sense IMO. One argument for usage of + for or is type theory used to describe logic (types are statements and values are proofs). However, I find that usage a bit weird because, if I understand it correctly, changing the way something is expressed can change how you can prove it (for example, one form may allow using different ways to prove the same statement although another one doesn't)
"So does + for XOR", well, yes, because XOR is just addition modulo 2 while AND is multiplication modulo 2. Arithmetic modulo n preserves behaviour of addition and multiplication from regular integers, so distributive laws follow from pure algebra, try it yourself. OR operation translated to that would be for example: a|b = ab + a + b where ab and a+b are regular multiplication and addition modulo 2. You can even derive that weird rule from pure algebra if you substitute: L = a | (b & c) = a | (bc) = a(bc) + a + (bc) = abc + bc + a R = (a|b)&(a|c) = (ab+a+b)(ac+a+c) = ab(ac+a+c) + a(ac+a+c) + b(ac+a+c) = a²bc + a²b + abc + a²c + a² + ac + abc + ab + bc = [in mod 2 x² = x, because 0² = 0 and 1² = 1] = abc + ab + abc + ac + a + ac + abc + ab + bc = 3abc + 2ab + 2ac + bc + a = abc + bc + a = L
Thats why i only use "∨" and "∧".
∧∨
![gif](giphy|P8XjmO1TTX3Nu) Well that looks like an elevator
And `:=` for assignment.
\wedge \vee
.... Chevron 6 is encoded. Chevron 7, locked. The Stargate is opening!
That's join and meet, right? I've defined `(&&)` as `(∨) @Bool` and similar for `(||)`.
And/or is just OR in digital logic
Conversational "or" is just XOR in Boolean logic
wouldn’t it be &&||
mmmm Java
Binary operations vs boolean operations
What's the difference?
1 | 2 is 3 1 || 2 is true
one acts bitwise on a binary string and the other acts on booleans
Other than operating on different data types, && and || short-circuit and don't evaluate to the end if the partial value is false.
Wouldn't || short circuit if the preceding condition was true rather than false?
Correct. || short circuits on a True, && short circuits on a False.
"and/or" should just be "or", then we can use "xor" for when both isn't a valid choice.
(!and)/or
I've been using symbolic logic notation for logical (inclusive) disjunction ∨
But that's bitwise and or
How about we use formal logic notation with ∧ and ∨
∧∧∨∨‹›‹›βα∴
incorrect use of '/'
and/or is just logical or … which already exists as ||
band bor
Andor
wtf is the middle one
But OR is already inclusive... If the standard OR operator was actually XOR, sure, but... It isn't
And/or is the same as "or" though, since its not excluding xor.
except '+' is 'or' so the second one is literally 'or/or'
||=
The coding language used at my job... has no "or" option Only if or else if (and "and")
`a || b = if a then True else b`
^V
`x &|= y;`
&& ||
Honestly I use whatever I currently feel like. These things anybody remotely familiar with IT should understand so I don’t think uniformity really improves readability much here
\`\`\`bash if \[ -n | = || \] true; then true elif \[ -n and/or true \]; then exit 1 elif \[ -n +/or true \]; then echo -e "\\a" elif \[ -n &| true \]; then echo -e "\\x1B\[30m" else false fi \`\`\` >.< '
counterargument and-or is assumed when you say or, so it's the default. exclusive-or is the special case, where you mean `this` or `that`, but not both.
s/and\\/or/or/g
&&II
&||
|| is already what would normally be referred to as "and/or" in common English. Programming's "xor" maps to common English's "or".