473,320 Members | 1,858 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,320 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 1743
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.