473,378 Members | 1,236 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,378 software developers and data experts.

about c

i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers

Sep 26 '07 #1
7 1745
DDD
On Sep 26, 10:39 pm, beginers of c <ssksak...@gmail.comwrote:
i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers
You have to shift a binary number to left 1 position and you want to
ask whether there is any code to do this operation?
I want to know how you get the binary number? from a file or just you
convert from other none binary number temporary?
If so, why not doing the shift after you get it as a none binary
number then convert it back.

Sep 26 '07 #2
"beginers of c" writes:
>i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers
Look up the << and <<= operators.
Sep 26 '07 #3
On Sep 26, 3:39 pm, beginers of c <ssksak...@gmail.comwrote:
i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers
The easiest way to left shift a number is to use the 'left shift'
operator << .

However, 0011 is not a left-shifted form of 1001. Are you sure you
want to left shift the number?

Sep 26 '07 #4
"J. J. Farrell" writes:
On Sep 26, 3:39 pm, beginers of c <ssksak...@gmail.comwrote:
>i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers

The easiest way to left shift a number is to use the 'left shift'
operator << .

However, 0011 is not a left-shifted form of 1001. Are you sure you
want to left shift the number?
I didn't even notice that. If the OP wants a circular shift he will have to
build it up out of the bits and pieces that C does offer.
Sep 26 '07 #5
vin
On Sep 26, 7:39 am, beginers of c <ssksak...@gmail.comwrote:
i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers
to left shift a number simply use the left shift opreator, which is <<

syntax: your number << the number of places you want to shift

hey m a newbie to C, so please tell me if i'm wrong, so that i can
correct myself.

Thank you

Sep 26 '07 #6
beginers of c <ss*******@gmail.comwrites:
i have a binary number
1001 .i have to left shift it to 1 position
like 0011.if their any datatype or code is available to shift the
binary numbers
That's not a shift. It looks like you want to do a rotate operation.
C doesn't provide an operator to do that directly, but you can program
it.

Incidentally, if you'll try to use better punctuation and
capitalization, it will be helpful to those of us who are trying to
help you. Capitalize the word "I" and the first word of each
sentence. Leave a space or two after the "." at the end of each
sentence; don't leave a space before it.

For example:

I have a binary number 1001. I have to left shift it to 1 position
like 0011. If their any datatype or code is available to shift the
binary numbers.

The grammar and spelling are still a bit off, but we can overlook
that.

Also, what *exactly* do you mean when you say you have a binary number
1001? Do you have a 4-character string with the value "1001"? Do you
have an integer object whose value would be 1001 if expressed in
binary (9 decimal)? In C, integers are always stored in binary, but
the language has no notation for binary constants (it only has
decimal, octal, and hexadecimal).

Finally, let me suggest that you choose a more specific subject, so we
can tell what you're asking about. Everything here is (or should be)
"about c". A subject like "binary left shift" or "binary left rotate"
wold have been better.

Please don't take offense at these suggestions; they're intended to be
constructive, so we can help you more effectively.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 26 '07 #7
beginers of c wrote:
>
i have a binary number
1001 .i have to left shift it to 1 position
like 0011.
That's a square root, not a shift.
if their any datatype or code is available to shift the
binary numbers
--
pete
Sep 26 '07 #8

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.