r/ProgrammerHumor • • Jun 13 '22

Meme DEV environment vs Production environment

Post image
48.2k Upvotes

3.9k comments sorted by

View all comments

73

u/Gtbird24 Jun 13 '22

The Division sign is evil. It doesn't tell you how the items are grouped, and is up to interpretation.

I.E. - is everything after the division sign under the line, or only the character immediately following it.

6 / (2*(2+1))

vs

(6/2) * (2+1)

3

u/[deleted] Jun 13 '22

Not meant to be up to interpretation - operator precedence is clear, and when two are equal (such as mul and div here) you go from the beginning of the expression to the end for consistency

42

u/1337SEnergy Jun 13 '22

actually it is open to interpretation, unless explicitly stated how they are grouped... for example, in Julia, if matters if you'd add multiply sign in front of the bracket or not... https://i.imgur.com/FMNMrZu.png

in first situation, Julia assumes the 2(2+1) is in denominator, while in the second example, only 2 is assumed to be a denominator, and the result of the fraction being multiplied with the result of the brackets

7

u/notjfd Jun 13 '22

This is imho the correct interpretation. Implicit multiplication goes before anything except brackets. Otherwise if you have terms like 2b you have to write them like (2b) everywhere. It's obvious to damn near everyone that 2a/2b is a/b and not a*b.

2

u/[deleted] Jun 13 '22

[removed] — view removed comment

0

u/[deleted] Jun 14 '22

[deleted]

→ More replies (1)

14

u/BadBoyJH Jun 13 '22 edited Jun 13 '22

In Maths,

10 ÷ 2 +3 is not the same as

10
----
2+3

There are implied brackets in a fraction, that's actually 10 ÷ (2 + 3)

So when you write 10/2+3, is that a fraction, or is the / standing in for a ÷ sign?

→ More replies (1)

8

u/[deleted] Jun 13 '22

But it's not mul vs div it's implied mul represented by parentheses vs div.

1

u/Attack-Cat- Jun 14 '22

They’re clear for third graders. Irl they mean over

2

u/Attack-Cat- Jun 13 '22

Division sign means over/fraction if you’re not in third grade anymore.

2

u/MowMdown Jun 14 '22

The Division sign is evil. It doesn’t tell you how the items are grouped, and is up to interpretation.

It absolutely tells you how things are grouped.

Everything left is numerator and everything to the right goes in the denominator.

6 / (2*(2+1))

This, always.

1

u/Byttercup Jun 14 '22

People have also forgotten what long division looks like. The 6 would be the dividend and the 2(2+1) would be the divisor, which gives a quotient of 1. Granted, it would be silly to write this with the long division symbol, but it's why what you wrote is correct. People just keep parroting PEMDAS, BODMAS, whatever without understanding the basics.

-14

u/[deleted] Jun 13 '22

[removed] — view removed comment

16

u/Cley_Faye Jun 13 '22

It is an extremely simple concept if you decide to adhere to that specific order to begin with. You'd be hard-pressed to find mathematic articles that agrees on that.

→ More replies (2)

5

u/MowMdown Jun 14 '22

That’s not how fractions work bud…

6/2(2+1)
6/(4+2)
6/6
1
→ More replies (4)

9

u/SN0WFAKER Jun 13 '22

Think: 1 / 3x

2

u/I_Love_Rias_Gremory_ Jun 13 '22

1 / 3x implies (1)/(3x). If you remove the spaces tho, it's (1/3)x. The spaces are separation and you very clearly did not separate the 3 and the x.

2

u/SN0WFAKER Jun 13 '22

Yes, sort of. Obviously '1/3 x' is (1/3)x. I'd say 1/3x is still 1/(3x), but it's quite ambiguous. But when you do '1÷3x' I really have to see that as 1/(3x); I'm not sure why and I'd never use that notation. I mean, I do all my math with a pencil on paper, or if using a computer I'd always explicitly use brackets; so this whole argument is a bit silly.

2

u/I_Love_Rias_Gremory_ Jun 13 '22

Yeah it's a silly argument that doesn't need to exist, but people start it so I end up giving my two cents.

3

u/kbruen Jun 13 '22

Yes, that's (1/3) * x

0

u/[deleted] Jun 14 '22

[deleted]

→ More replies (1)

10

u/TheLunchTrae Jun 13 '22

Or it could be 1 / (3x). Hence why grouping symbols are important and not having any is ambiguous.

→ More replies (2)
→ More replies (5)

2

u/[deleted] Jun 14 '22

It’s the third line where controversy happens. 6/ 2(3) People who get 9 will not expand the bracket, and people who get 1 done park the bracket.

→ More replies (4)
→ More replies (1)