• @Omega_Haxors@lemmy.ml
    link
    fedilink
    English
    16
    edit-2
    4 months ago

    Computers multiply by adding, subtract by adding, i’m not sure how division goes but i’m sure that’s addition too.

        • @icydefiance@lemm.ee
          link
          fedilink
          English
          4
          edit-2
          4 months ago

          The other replies are simplifying too much. Just adding or subtracting in a loop would be far too slow.

          A multiplier will find the partial products by using AND gates, and then sum them, which is very similar to long multiplication as they teach you in school. This article explains it pretty well.

          Division is more complicated. It’s sort of done like long division, but apparently that is slow and there’s some magic with two’s complements that can make it faster. Honestly I don’t fully understand it yet.

          • @SturgiesYrFase@lemmy.ml
            link
            fedilink
            English
            24 months ago

            That article was really good. I feel like if someone explained it to me at a pub or party I could somewhat talk about it without sounding like a total ludite.

        • Johanno
          link
          fedilink
          English
          44 months ago

          Once you go down to logic gates. A XOR gate for example makes 1+1 = 0

        • Xavienth
          link
          fedilink
          English
          24 months ago

          Subtract divisor from dividend until you hit zero. Number of subtractions is the quotient. Don’t ask about non-whole numbers.

        • @Omega_Haxors@lemmy.ml
          link
          fedilink
          English
          2
          edit-2
          4 months ago

          It recursively subtracts until the number goes at or below zero. The iterations is the output and the reminder is how much it went below zero.