Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic operators using bitwise operators [closed]

Tags:

c++

c

Is there a way to perform addition(or arithmetic operations) by using ONLY bitwise operators?

like image 948
Srikanth R Avatar asked Nov 08 '12 06:11

Srikanth R


People also ask

What arithmetic operators can be used for performing bit wise left shift operation?

The following operators perform bitwise or shift operations with operands of the integral numeric types or the char type: Unary ~ (bitwise complement) operator. Binary << (left shift), >> (right shift), and >>> (unsigned right shift) operators.

Where is using bitwise operations faster than doing arithmetic operations?

Yes, Bitwise operations are alot faster than any arithmetic operations because these operations are performed directly on the bits that is 0 and 1. In this operation we will get the output Odd.

Are bitwise operations faster than arithmetic?

Bitwise operations are incredibly simple and thus usually faster than arithmetic operations.


1 Answers

You can search for some hardware designs for arithmetic operators. For addition example, you can find full adder, half adder, then ripple carry adder, carry save adder, carry lookahead adder. Then you can generate lots of code to use bit-wise operators to do those arithmetic operations.

like image 199
jclin Avatar answered Oct 25 '22 06:10

jclin