Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Logical shift and arithematic shift

Status
Not open for further replies.

sunidrak

Full Member level 1
Joined
Apr 12, 2012
Messages
97
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Bengaluru, India
Activity points
1,738
If we do 1bit logical left shift in a 8 bit register then the

new value=2 times the old value
suppose the Old value is 10000010 (130 in decimal)
then the New value 00000100 (4 in decimal)
then the statement left shift will produce 2 times the old value will not be true

can anybody plz explain how it hold true ??
If we do 2bit left shift then the new value will be 4 times the old one ?? Wat is relation ??
 

The statement holds true as long as you don't exceed the given bit length max value (255 for 8 bit), if you exceed it then you get a truncated result , the same as if you try to do it using

Code:
uin8_byte = 130 * 2;

If you try it with a 16bit data type then it will work fine in both cases.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top