Binary Calculator

May 19, 2020 at 8:38pm
hello there, i'm searching for a binary calculator for addition, subtraction, multiplication, i have been searching for a while and not found a simple one, near 50 line or something around it, just a simple one, can anyone help?
Last edited on May 19, 2020 at 8:44pm
May 19, 2020 at 8:46pm
When you say "binary" are you referring to binary operators (a + b), or are you referring to binary numbers (01001100)?

Also, if you post code that you're having trouble with, we can try to help.
Last edited on May 19, 2020 at 8:46pm
May 19, 2020 at 8:52pm
Hello Gandao, i'm referring to "10101010" + "11001100", i dont have any code because i dont understand the binary system



https://www.calculator.net/binary-calculator.html
May 19, 2020 at 9:03pm
Well, if you're just looking for code, try searching GitHub.
https://github.com/KDKaczkowski/Binary-numbers-calculator
May 19, 2020 at 10:37pm
a simple one would just jack text input and text output into the numbers, and do the math on the cpu. You could do all that in what, < 10 lines? Unless you need more than 64 bits? Why not take a crack at it that way, and learn something as you do it?

binary is very simple. it works exactly like base 10 does.
first, the numbers are made up of powers of 2, where a 0 is worth 0 and a 1 is worth that power of 2.
consider:
1,2,4,8,16,32,64,128,256,512,...
what is the number '5', then?
its 4+1.
101 where the least bit is the 1 position, the zero is the 2s position, the next 1 is the 4 position, 4+1 is 5. easy.
what is 3, then? 2+1. 011.
lets add them.
101
011
-----
--0 carry the 1

010 //carry
101
011
-----
-00 //carry the 1 again..
ends up being 1000 (just like addition in base 10 would work)
which is... 8 (8+0 4s + 0 2s + 0 1s)

and so on. multiply works just like base 10, so does long division.

but the computer already knows how to do all that. again, all you need is text to number and number to text for binary.
Last edited on May 19, 2020 at 10:45pm
Topic archived. No new replies allowed.