bit-manipulation

Count set bits in an integer

Posted on Updated on

Problem Statement:

Write a program to count number of 1’s in binary representation of an integer.

Read the rest of this entry »

Subtract two numbers without using arithmetic operators

Posted on Updated on

Problem Statement:

Subtract two numbers without using arithmetic operators

Write a function subtract(x, y) that returns x-y where x and y are integers. The function should not use any of the arithmetic operators (+, ++, –, -, .. etc).

Read the rest of this entry »

Add two numbers without using arithmetic operators

Posted on Updated on

Problem Statement:

Add two numbers without using arithmetic operators

Write a function Add() that returns sum of two integers.
The function should not use any of the arithmetic operators (+, ++, –, -, .. etc).

Read the rest of this entry »