Connecting Tech Pros Worldwide Forums | Help | Site Map

about c

beginers of c
Guest
 
Posts: n/a
#1: Sep 26 '07
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


DDD
Guest
 
Posts: n/a
#2: Sep 26 '07

re: about c


On Sep 26, 10:39 pm, beginers of c <ssksak...@gmail.comwrote:
Quote:
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.

osmium
Guest
 
Posts: n/a
#3: Sep 26 '07

re: about c


"beginers of c" writes:
Quote:
>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. Farrell
Guest
 
Posts: n/a
#4: Sep 26 '07

re: about c


On Sep 26, 3:39 pm, beginers of c <ssksak...@gmail.comwrote:
Quote:
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?

osmium
Guest
 
Posts: n/a
#5: Sep 26 '07

re: about c


"J. J. Farrell" writes:
Quote:
On Sep 26, 3:39 pm, beginers of c <ssksak...@gmail.comwrote:
Quote:
>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.


vin
Guest
 
Posts: n/a
#6: Sep 26 '07

re: about c


On Sep 26, 7:39 am, beginers of c <ssksak...@gmail.comwrote:
Quote:
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

Keith Thompson
Guest
 
Posts: n/a
#7: Sep 26 '07

re: about c


beginers of c <ssksakthi@gmail.comwrites:
Quote:
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) kst-u@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"
pete
Guest
 
Posts: n/a
#8: Sep 26 '07

re: about c


beginers of c wrote:
Quote:
>
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.
Quote:
if their any datatype or code is available to shift the
binary numbers
--
pete
Closed Thread