Binary Computation through PHP

In one of my recent interview coding questions, I was asked to write a function that would add two numbers but without arithmetic expressions. I thought to myself, how exactly would you be able to do that? What could they be referring to? After numerous Google searches I stumbled upon someone mentioning 2’s complement. Binary computation is how computers really add numbers, at the lowest levels. Machine language. I spent most of my weekend trying to figure this code out. I had to refresh my memory on how to calculate 2’s complement. It’s actually pretty simple once you get the basics down. Putting it in code is another thing. Anyways, check out my code: Bitwise.php

Comments

Write a Reply or Comment

Your email address will not be published. Required fields are marked *


www.000webhost.com