about c

B

beginers of 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
 
D

DDD

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.
 
O

osmium

beginers of c said:
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.
 
J

J. J. Farrell

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?
 
O

osmium

J. J. Farrell said:
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.
 
V

vin

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
 
K

Keith Thompson

beginers of c said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top