Recent comments in /f/explainlikeimfive

Flair_Helper t1_iycb2w2 wrote

Please read this entire message

Your submission has been removed for the following reason(s):

Questions about a business or a group's motivation are not allowed on ELI5. These are usually either straightforward, or known only to the organisations involved, leading to speculation (Rule 2).

If you would like this removal reviewed, please read the detailed rules first. If you believe this submission was removed erroneously, please use this form and we will review your submission.

1

Ikhtionikos t1_iycazgz wrote

Many basic misconceptions regarding multiplications can be dispelled if you just remember that multiplication is a type of addition, written in shorter form.

If you have 1+2×3, you don't have one plus two, followed by times-three, but, broken down, you have one, plus three times two (or two times three)

Thus, 1+2×3=1+2+2+2 -how many times you have the number two? Three times. Or, 1+2×3=1+3+3. -how many times you have the number three? Two times. Both sets of addititon thus equal 7.

For the same reason, you can't "multiply" irl an actual object or set of nultiple ojects by zero, because in that case your definition is erroneous.

1

Kalirren t1_iycayo7 wrote

And the answer to the "why" is because exponentiation distributes over multiplication, and not the other way around, just like multiplication distributes over addition.

xy^(2) = x*(y^2) = x*y^2 != (x*y)^2 = (xy)^(2) = x^(2)y^(2)

x*(y^2) != (x*y) ^ (x*2)

3

RealUglyMF t1_iycap57 wrote

I doubt anyone is able to fully answer this as everyone who has done it so far hasn't survived to tell the story.

I imagine that it would vary from case to case depending on the actual cause of death, but I believe that passing peacefully while sleeping is definitely something that can happen

4

Symbian_Curator t1_iycacc6 wrote

I just want to point out, GOTO is not completely pointless, but the industry is used to repeating how GOTO is terrible without thinking much about the reasons, the reasons being as you pointed out, but also, valid uses for GOTO are so few and far between that it's just easier to teach new programmers to simply never use it.

About those valid uses:

  • In C, to mimic the destructor behaviour of C++ in function. For example, let's say that in function F you have: initialize resource A, initialize resource B, initialize resource C, do some work, clean u C, clean up B, clean up A. Then, in the code, you would try to init A, and if it works, carry on, but if not, exit the function. Try to init B, and if it works, carry on, but if not, GOTO "clean up A" part. Try to init C, and if it works, carry on, but if not, GOTO "clean up B" part. When you GOTO like this, the code "falls through" to clean up only the resources which were initialized. I was told that this technique is used widely in the code of the Linux kernel, but honestly I haven't bothered to check myself.
  • With some compiler extensions, computed GOTOs (where you can take the address of a GOTO label, put it in a lookup table, and jump based on some index) present a optimization opportunity for performance critical code, notably interpreters for other languages or bytecode of other languages. (it's similar to switch/case, just faster)
11

bildramer t1_iyca5ey wrote

Fun fact: (with some assumptions about operators) only one of the cyclic permutations of a RPN (or PN) string is valid, so you can be sneaky and define the value of any string as the value of the only parsable-as-RPN cyclic permutation of it, leading to funny stuff like 1 + 2 - 3 = 2, 5 * 6 - 7 + 8 * 9 = 368. Another fun fact: all strings with N numbers and N-1 binary operators are valid under that scheme, such as - + 8 7 * 6 5 * * 4 3 = 169. Proofs are an exercise to the reader.

2

Kalirren t1_iyc9jnx wrote

Nope. Subtraction is adding the additive inverse and doesn't distribute over multiplication. The reason why we have PEMA is because Exponentiation distributes over Multiplication and Multiplication distributes over Addition and Parentheses break those rules so you have to do the Parentheses first.

2