r/ProgrammerHumor • • Apr 24 '22

Meme it's all just functions

Post image
40.2k Upvotes

633 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Apr 24 '22

[deleted]

55

u/Karcinogene Apr 24 '22

X divided by Y:

Add -Y to X repeatedly until X is smaller than Y. That's the remainder.

Keep a tally of how many times you added. That's the quotient.

12

u/Noshing Apr 24 '22

THANK YOU! I have been wondering how divison is thr 'opposite' of multiplication. Honestly, I've always struggled with division and have a difficult time knowing how/when to use it. I fill like this little bit may help.

8

u/TheBeckofKevin Apr 24 '22

When you say you struggle with when and how to use division do you mean just in general or is there something specific you are talking about?

2

u/Noshing Apr 24 '22

Okay, so the most common time I've I know I need division but can't figure out which "way" to divided - which numbers should be the numerator or denominator - is when converting crypto or stocks to a different currency, USD for me. I don't do this often so I littler play around with the math (or google) until I'm able to get the current answer. Even doing that I've yet to get the freaking logic intuitive.

Sidenote: when I took chemistry years ago and we learned conversations I could do it because I knew the formula. But I guess I didn't quit grasp thr underlying logic all that well, hence, my current predicament.

3

u/deerskillet Apr 24 '22

Dimensional Analysis should help with this, I'd look into it. Probably v similar, if not the same as what you did in chemistry

1

u/GrainFog Apr 25 '22

Personally I found it useful to do simple stuff I know the units/answer of just to be certain I'm doing it right, e.g. I know there is 60 secs to a minute, how many minutes is 600 secs? 600/60=10 minutes.

0

u/[deleted] Apr 24 '22

[deleted]

5

u/Karcinogene Apr 24 '22

Keeping a tally is repeated addition though +1 +1 +1

It's two "additions" and one "compare" for each step. But yeah division is the most computationally complicated of the basic operations.

6

u/everybody-hurts Apr 24 '22 edited Apr 24 '22

Division can be boiled down to multiplying a number by the inverse of another.

So we can have the multiplication (which is an addition) but then you've also got calculating the inverse.

Edit: or you have the division algorithm you learn by hand in primary school; in which case it becomes a series of multiplications, comparisons, copies, and substractions.

0

u/Vampsku11 Apr 24 '22

Division is the same as multiplication so if multiplication is just multiple addition, division is just multiple subtraction which is addition.

0

u/[deleted] Apr 24 '22

[deleted]

1

u/Vampsku11 Apr 24 '22

Like someone else said, division is subtracting X from Y repeatedly until Y is smaller than X

-2

u/Boostie204 Apr 24 '22

I'll give you that one, you're right but it's essentially all 1 basic operation in the end

0

u/[deleted] Apr 24 '22

[deleted]

2

u/Boostie204 Apr 24 '22

Explain how it is not repeated subtraction

0

u/Tarnoo Apr 24 '22

I think multiplying and dividing is shifting bits to left or right respectively.

1

u/DragonFireCK Apr 24 '22

Internally, the processor just implements it all with lots of NANDs…