CFanatic

Go Back   CFanatic > Programming > C Programming

Join CFanatic Forum Now

shift operation on a negative number. topic posted under C Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2010, 03:23 AM
Junior Member
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
avee137 is on a distinguished road
| More
shift operation on a negative number.

please explain shift operation on negative numbers.
i executed a demo as below:
Code:
char c=-1,d,e;
d=c9;
it yields d=0 ,which i could understand as it works like a normal shift operation where bits are discarded as they move out of the word and bits on right side get filled by all 0's,

and e=-1,
and this i could not figure out as even after shifting it by 9 bits it holds the value intact.


any relevant explanation or reference would be a great help.
Reply With Quote
  #2  
Old 09-02-2010, 03:56 AM
Senior Member
 
Join Date: Sep 2010
Location: Kolkata, India
Posts: 307
Thanks: 0
Thanked 15 Times in 15 Posts
techforum4u is on a distinguished road
| More
Re: shift operation on a negative number.

how is it possible if it is thought from a variable point of view?? computer does not discriminate between c and e... variable can be anything...can you post a full proof code so that i can test that in my system...?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
number system sayantani nath C Programming 1 09-02-2010 04:07 AM
Random number. Danny_501 C Programming 0 08-28-2010 03:11 AM
counting positive and negative numbers jeanlouis.magannig C++ Programming 1 08-09-2010 10:39 AM
Macro operation techme C Programming 2 05-21-2010 02:25 AM
zero shift More options Mike C Programming 0 03-30-2007 01:15 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 02:34 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board