Search code examples
mathcomputer-sciencetheorynumber-theory

How does addition work in Computers?


I was watching a video on computer architecture and a question came to my mind. How does addition and basic operations work on computers? I mean, i know that 2+2 = 4 but i don't know why? i just know that if i add 2 apples to another 2 then i see 4, but is there a possible demonstration of this?

My question being is, how does a computer know that 2 + 2 = 4 at the most basic level? i know there are functions that add numbers, but at a basic level how is that addition performed?

I just want to know this to understand better how computers work as the most basic and used operation performed by a computer is the sum ( i believe )


Solution

  • At the "very bottom" numbers are just binary, and physical electronic hardware is used to perform the addition operation itself1 (where each bit in the number is represented by an on/off of the physical circuit line) - this is done by some variation of an an Adder circuit.

    For "how" the math works see Two's complement: Aritmetic, which is the most commonly used integer encoding. Conceptually such arithmetic is similar to that of other bases, such as base-10/decimal taught in school.


    1 Modern/conventional computers: there have been mechanical computers (at least insofar as 'calculating machines'), analog computers, and takes on quantum computers, etc.