How Computers Do Their Calculations

Nisal Jayathilaka
2 min readDec 20, 2021

Do you know how computers do the calculation? I know a lot of them are not aware of it. This article will help you to clarify concerns about computer calculations. If you do the programming this will help you much more.
Let’s jump into the problem. Do you know what is the answer for 125 plus 6? Yes, it’s 131. How about this

byte a =125; , byte b = 6; byte c = a + b;

what will be the answer? Take 1 min for that question give the answer.

Is it true? The answer is Yes you know the way If it is not you do not know the way how to calculate”. Is it 131byte or Exception or -125byte

If it is -125 your answer is correct. what…. is it -125 how that happen? Let’s talk about how that happened. Normally when doing the calculation it is in a linear format.

liner way

But computers circularly do calculations. In a Circular way? Yes in a Circular way.

Circle way

It doesn’t have any end. According to our example byte range is ended in 127 to -128

So, 125 + 6 = 127 and we have 4 add it goes up to (-128, -127, -126, -125) And the answer should be = byte -125;

The answer calculation

In computer do for that for any data type for their range for examples (int, float, double…).

I think now you have an idea about how computers do calculations.

Remember when do you do the computer calculation it is not ended it goes around a circle way.

--

--