473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to get the bit after shifted?

e.g.
int i = 5; // i.e. 0000...101

// shift i to the right

int j = i >1; // how to get the `one` being shifted?

thanks.

Oct 26 '06 #1
4 1693
howa wrote:
e.g.
int i = 5; // i.e. 0000...101

// shift i to the right

int j = i >1; // how to get the `one` being shifted?
I think you are asking how to save the LSB of i. If so, the answer is
to use logical-and, but it must be done before the shift:

int k = i & 1; // Save a copy of the LSB
int j = i >1; // Now the LSB is gone

Cheers! --M

Oct 26 '06 #2
howa wrote:
e.g.
int i = 5; // i.e. 0000...101

// shift i to the right

int j = i >1; // how to get the `one` being shifted?
int k = (i & 1);

--
Clark S. Cox III
cl*******@gmail.com
Oct 26 '06 #3
mlimber wrote:
>
I think you are asking how to save the LSB of i. If so, the answer is
to use logical-and, but it must be done before the shift:

int k = i & 1; // Save a copy of the LSB
int j = i >1; // Now the LSB is gone

Cheers! --M
I believe you mean bitwise-and?
Oct 26 '06 #4
Eric wrote:
mlimber wrote:

I think you are asking how to save the LSB of i. If so, the answer is
to use logical-and, but it must be done before the shift:

int k = i & 1; // Save a copy of the LSB
int j = i >1; // Now the LSB is gone

Cheers! --M

I believe you mean bitwise-and?
So I did. I used the right one in the code, but spelled it wrong in the
text.

Cheers! --M

Oct 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: (Pete Cresswell) | last post by:
A stored procedure is returning three recordsets via ADO. Two of the recordsets have columns with names like "Estimate1", "Estimate2", "Estimate3", "Estimate4", "Estimate5", and "Estimate6". ...
4
by: Kalpesh Parikh | last post by:
We have 'C' routine calls Pro COBOL routine...... Data passed back to the C program is shifted by 4 bytes. We are trying to understand and fix this. p.s. COBOL to COBOL is working fine! Any...
5
by: VK | last post by:
On the demo at <http://www.geocities.com/schools_ring/tmp/demo01/index.xml> the table caption has 1px(?) indentation from the left in Firefox 1.5 and I'm running out of ideas how to kill it - if...
4
by: rukkie | last post by:
After a redisplay of the form, caused by errors in other fields, the text which is in the "Observ" textarea is shifted (some 8 places) to the right (and this each time after a redisplay). The code...
0
by: amyl | last post by:
I have a 32 bit number "3515261219" that really contains four 8 bit numbers. 11010001 10000110 10100001 00100011 Is there a way to capture the bits that are shifted out of the number when you...
5
by: Eric Lilja | last post by:
Is there something "elegant" in the standard library I can use to perform a "shifted insert" in a std::string? Let me examplify what I mean with shifted insert. Say I have: std::string foo =...
6
by: dontwantspam | last post by:
Hello everyone, I'm working on this css site redesign http://www.maranathamalta.com/4given/testingmain.php I've tested on my machine running XP using Firefox 2.0.0.4, IE6 and IE7. It looks...
4
by: Vols | last post by:
I found the following question, and couldn't get the best answer: if you have a sorted and shifted array such like {5,6,7,1,2,3,4}, how to find one element "2"? Thanks. Vol
1
by: hoskinsdennis | last post by:
Hey hey forum!!! I'm pretty new to website coding but trying to make a go of it, and having some serious issues with IE www.allfiredupinc.com Why do I have to put a hack in to correct the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.