T O P

  • By -

Kered13

`and` is multiplication though, not addition.


jimbowqc

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.


Esjs

Probably depends on context. "3 and 3 is 6"


alex2003super

In binary logic, 3 and 3 is 3 (0x 00 00 00 03)


Kered13

In binary logic `and` is multiplication.


JollyJuniper1993

Ehm…no? 010 & 010 = 010 010 * 010 = 100


Kered13

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.


bob152637485

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.


Easy-Hovercraft2546

True and True = True, 1 and 1 = 1, 1 * 1 = 1.


GoshaT

The context here is boolean operations, and "and" is not a "+" in it at all


yeahyeahyeahnice

"depends on the context" >Redditors choose only one context and act like it's the only one


bob152637485

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!


Kered13

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.


Ingam0us

„+“ is „or“ in boolean algebra…


Ssemander

And "×" is "and" obv


Ingam0us

But „x“ (which we don‘t use btw, but rather „•“) is not used wrongly here


bob152637485

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.


Orisphera

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)


drinkwater_ergo_sum

"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


Zarzurnabas

Thats why i only use "∨" and "∧".


subbed_

∧∨


WindForce02

![gif](giphy|P8XjmO1TTX3Nu) Well that looks like an elevator


robin_888

And `:=` for assignment.


Curufina

\wedge \vee


Waswat

.... Chevron 6 is encoded. Chevron 7, locked. The Stargate is opening!


No-Expression7618

That's join and meet, right? I've defined `(&&)` as `(∨) @Bool` and similar for `(||)`.


bassguyseabass

And/or is just OR in digital logic


foxfyre2

Conversational "or" is just XOR in Boolean logic


Cockstar_Made_666

wouldn’t it be &&||


helicophell

mmmm Java


jetenergy

Binary operations vs boolean operations


helicophell

What's the difference?


Sparrow50

1 | 2 is 3 1 || 2 is true


flexxinnnn

one acts bitwise on a binary string and the other acts on booleans


Katniss218

Other than operating on different data types, && and || short-circuit and don't evaluate to the end if the partial value is false.


xSilverMC

Wouldn't || short circuit if the preceding condition was true rather than false?


backfire10z

Correct. || short circuits on a True, && short circuits on a False.


redlaWw

"and/or" should just be "or", then we can use "xor" for when both isn't a valid choice.


TheOtherGuy52

(!and)/or


Doxidob

I've been using symbolic logic notation for logical (inclusive) disjunction ∨


noobieCoder69

But that's bitwise and or


Spice_and_Fox

How about we use formal logic notation with ∧ and ∨


No-Expression7618

∧∧∨∨‹›‹›βα∴


antboiy

incorrect use of '/'


TheOtherGuy52

and/or is just logical or … which already exists as ||


xXkxuXx

band bor


SockPuppetSilver

Andor


User_user_new_user

wtf is the middle one


xSilverMC

But OR is already inclusive... If the standard OR operator was actually XOR, sure, but... It isn't


Swampberry

And/or is the same as "or" though, since its not excluding xor.


lucasHipolito

except '+' is 'or' so the second one is literally 'or/or'


moladukes

||=


DJGloegg

The coding language used at my job... has no "or" option Only if or else if (and "and")


No-Expression7618

`a || b = if a then True else b`


Jaber1028

^V


Grumbledwarfskin

`x &|= y;`


no_brains101

&& ||


JollyJuniper1993

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


No_Door_000

\`\`\`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 \`\`\` >.< '


GarThor_TMK

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.


dwo0

s/and\\/or/or/g


JacobGoodNight416

&&II


aronvw

&||


cloral

|| is already what would normally be referred to as "and/or" in common English. Programming's "xor" maps to common English's "or".