**left shift operator behaves like left rotate when the operand is a variable.**Below is a snippet of code and the result (compiler version also
mentioned). I fail to understand why the left shift operator behaves
as if it were the left rotate operator when the operand is a variable.
$ cat test.c
#include <stdio.h>
int main(void)
{
unsigned int a = 32, b = 33;
printf("with constants 1 << 32 = %u, 1 << 33 = %u\n", 1<<32,
1<<33);
printf("with variables 1 << 32 = %u, 1 << 33 = %u\n", 1<<a, 1<<b);
return 0;
}
$ gcc test.c
test.c: In function 'main':
test.c:6:5: warning: left shi...

**Left Shift / Right Shift Operators**Hi,
Is there any way to catch the losing bit occurring due to Right Shift
Operator ?
e.g
int a = 5 ;
a = a >> 1 ; // // a is now 2 and the least significant bit is lost //
//
I want this solution for the question:
"How to find if the number is even or odd using only "<<" or/and ">>"
operators ?"
On Thu, 29 Nov 2006, Santosh Nayak wrote:
>
> Is there any way to catch the losing bit occurring due to Right Shift
> Operator ?
int a = 5;
int lost_bit = a & 1;
a = a >> 1;
/* now lost_bit holds the lost bit */
> ...

**Java left shift and right shift operators.**I have a problem where I have to do left shift and right shift.
Long N;
int shiftby;
output = N >> shiftby;
Above N is shifted right.
Example if N=11101101 [binary value]
will become: 1110110 when shiftby=1;
will become: 0111011 when shiftby=2;
will become: 0011101 when shiftby=3;
will become: 0001110 when shiftby=4;
will become: 0000111 when shiftby=5;
will become: 0000011 when shiftby=6;
will become: 0000001 when shiftby=7;
When I want to shift left I can use
output = N << shiftby; //[Not change in sign "<<" instead of ">>"]
Above N is shi...

**Shift operator**Hi (again)!
Anyone knows how the vhdl shift operator (shr or shl) is implemented?
Ex: out_var := shr(inp_value,inp_shr);
Is it synthesized to a barrel shifter? I guess this requires a lot of
logic, anyone have a rough idea how much area/gates a 32-bit barrel
shifter needs? From the standard "triangle" layout, it looks like the
area grows with a factor 4, so that a 64-bit barrel shifter consumes 4
times as much hardware as a 32 bit. Anyone knows if this is correct?
Lots of questions... : )
Best regards,
Andreas Lundgren
...

**rotate operators**Hi,
Can I suggest using !>> and <<! for right and left rotate operations
respectively ?
Rob
"Robert Finch" <robfinch@sympatico.ca> wrote in message
news:F1_Md.4718$lw4.1016414@news20.bellglobal.com...
> Hi,
>
> Can I suggest using !>> and <<! for right and left rotate operations
> respectively ?
Suggest away. But this isn't really the best group
for that. The group where the C++ standard and its
future directions are discussed is comp.std.c++.
Here we try to keep the discussion about the language
in its current form.
-Mike
Ro...

**Shift operators.**If i'm shifting an integer 'n' times where n > sizeof(int), It's giving
the same value as
that of n-sizeof(n). Why is it behaving like this. I studied that the
bit 'll be replaced by '0'.
Example;
int i = 1;
printf ("%d\n", i<<32);
o/p: 1.
int i = 2;
printf ("%d\n", i<<33);
o/p: 2.
Le 14-06-2006, deepak <deepakpjose@gmail.com> a �crit�:
> If i'm shifting an integer 'n' times where n > sizeof(int), It's giving
> the same value as
> that of n-sizeof(n). Why is it behaving like this. I studied...

**Shift Operation**Hi All,
Could you please explain whether C standard supports logical right
shift operation using some operator?
I know somewhere I read about >>> operator. I thought, it is in C but i
think i'm wrong about it. No where google helps me determining this
lapse in my memory. MSVC 6 compiler gives me error.
Thanks && Regards,
Nishu
Nishu said:
> Hi All,
>
> Could you please explain whether C standard supports logical right
> shift operation using some operator?
C's right shift operator, >>, works like this:
A >> B will yield a result that is...

**Rotate operators**Hi all,
In xHarbour compiler there are left-shift(<<) and right-shift(>>) operators.
Very good. But in many implementations it can be usefull left-rotate and
right-rotate operators. Especially for data packing/crypting, because no
bit lossing occures.
Well known C compilers have not theese operators and users with assembler
practise in tears remember such good ROL and ROR assembler instructions.
What do you thing about this ?
With best regards,
also in tears
Saulius
Saulius
> In xHarbour compiler there are left-shift(<<) and right-shift(>>)
> operators.
...

**shift operator**hi all,
can anyone please tell me how to do a left shift in the folowing
manner.
suppose there are 5bits: 10010 now i have to shift left such that 1st
bit should go to the last position i.e 00101. when I use "<<" operator
the last position is appended with 0 i.e 00100. Is there any operator
in verilog to use?
Thanks a lot.
Regards,
Raghu
On 5 Jul 2006 00:08:24 -0700, "raghu" wrote:
>can anyone please tell me how to do a left shift in the folowing
>manner.
>suppose there are 5bits: 10010 now i have to shift left such that 1st
>bit sh...

**US-PA: Philadelphia-Computer Operator-Print Operator -night shift****************************************************************
JobCircle.com is the largest regional job board in the
Mid-Atlantic region, with tens of thousands of job offerings
in PA, NJ, DE, MD, NY, and Washington D.C. To learn more,
visit http://www.jobcircle.com?source=ng
**************************************************************
Job Title: Computer Operator-Print Operator -night shift
Job Location: PA: Philadelphia
Pay Rate: per Hour
Job Length: full time
Start Date: 2009-02-25
Company Name: Kforce Professional Staffing
Contact: John Vagie
Phone: ...

**problem with shift operation**I hav the follwoing simple code which does left shifting operation.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity counter is
port (
q: inout STD_LOGIC_VECTOR (3 downto 0);
clock: in STD_LOGIC;
reset: in STD_LOGIC;
en: in STD_LOGIC
);
end counter;
architecture counter of counter is
signal count:std_logic_vector(3 downto 0):="0000";
begin
process(clock,reset)
begin
if reset='0' then
count<="0000";
elsif(clock='1') then
if en='1' then
l1: for i in 1 to 3 loop
...

**bitset rotational shift?**I need to do rotational shift on bitset. But I couldn't find that
operation in the standard. Is there any workaround or other packages to
do this?
Thanks,
Peng
In article <1143439864.704032.283850@i39g2000cwa.googlegroups.com>,
"PengYu.UT@gmail.com" <PengYu.UT@gmail.com> wrote:
> I need to do rotational shift on bitset. But I couldn't find that
> operation in the standard. Is there any workaround or other packages to
> do this?
You can do it the same way you would on an unsigned integral type (which
shifts):
#include <bitset>
#include <st...

**shift right operator**main()
{
int a =100;
a = a>>32;
printf(" %d", a);
}
it prints "a" as 100 only....but I am expecting a = 0.....
can some one tell me the reason?
bye
Deepak\
DeepaK K C wrote:
> main()
> {
> int a =100;
> a = a>>32;
> printf(" %d", a);
> }
>
> it prints "a" as 100 only....but I am expecting a = 0.....
> can some one tell me the reason?
It's a manifestation of undefined behaviour. (Some machines
only have a 5-bit shift count, for example.)
What happens if you turn your compiler warnings up?
--
Chris "...

**Rotate Matrix operator?**Dear all
has anybody handle such a strange transfer of matrix? like
1 2 3 operator?? 1 0 0
4 5 0 -------------> 4 2 0
6 0 0 6 5 3
it seems like to nip the first row vector as the diagonal
terms of new matrix, the second row also clockwise rotates
45 degree, and so on.. the rest triangle upper part are
taken to be zero. Maybe it is stupid, but if you know how to
make it or it does exist a command in Matlab, please let me
know.Thank you very much.
"william riker Tang" <williamriker.tang@gmail.com> wrote in
message <g1dmir$mqg$1@fred...

**Operation Blue Shift**http://ps-2.kev009.com/pccbbs/
250GB of RickE. Goes to 2008 or so.
Regards,
--
Kevin Bowling
Free Comp.* Usenet access at http://csiph.com/
On 3/1/2012 2:05 AM, Kevin Bowling wrote:
> http://ps-2.kev009.com/pccbbs/
>
> 250GB of RickE. Goes to 2008 or so.
>
> Regards,
I had some directory permissions wrong so most of the new stuff wasn't
even visible. This has been fixed.
--
Kevin Bowling
Free Comp.* Usenet access at http://csiph.com/
...

**Rotate Matrix operator? #2**Dear all
has anybody handle such a strange transfer of matrix? like
1 2 3 operator?? 1 0 0
4 5 0 -------------> 4 2 0
6 0 0 6 5 3
it seems like to nip the first row vector as the diagonal
terms of new matrix, the second row also clockwise rotates
45 degree, and so on.. the rest triangle upper part are
taken to be zero. Maybe it is stupid, but if you know how to
make it or it does exist a command in Matlab, please let me
know.Thank you very much.
...

**Problem with shift operation #2**I hav the follwoing simple code which does left shifting operation.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity counter is
port (
q: inout STD_LOGIC_VECTOR (3 downto 0);
clock: in STD_LOGIC;
reset: in STD_LOGIC;
en: in STD_LOGIC
);
end counter;
architecture counter of counter is
signal count:std_logic_vector(3 downto 0):="0000";
begin
process(clock,reset)
begin
if reset='0' then
count<="0000";
...

**Regarding left shift operator**Respected Experts,
Iam RaviKumar.N, I have a query regarding left shift operator.
Consider the following variables:
1) unsigned char a = 2;
2) unsigned char b = 3;
3) unsigned short c;
Consider the following expression:
c = (unsigned short)(( a << 8) | b);
My query is:
"Is it valid to shift a byte value by an 8-bit".
I got this expression compiled,but Iam not sure about the results I got.
Please let me know about this.
With Regards
Ravi Kumar.N
> Respecte...

**shift operator undefined behavior**Hi,
I was expecting:
int main( int argc, char *argv[] )
{
unsigned char m = 32;
register unsigned mask = (1<<m);
std::cout << std::hex << mask << '\n';
return 0;
}
to print 0 but instead this program compiled with g++ prints 1!
If I change (1<<m) by (1<<32) or if change the program for
int main( int argc, char *argv[] )
{
unsigned char m = 31;
register unsigned mask = (1<<m)<<1;
std::cout << std::hex << mask << '\n';
return 0;
}
it gives me the expected 0.
In the C++ standard docume...

**Negative values for shift operators.**K&R states that the right operand must be non-negative.
"The shift operators << and >> perform left and right shifts of their
left operand by the number of bit positions given by the right operand,
which must be non-negative"
unsigned int n = 10;
n <<= -2;
MSVC7 accepts this above code as valid and compiles it.
Should this be allowed, it seems like it could lead to subtle bugs?
rcn
ritesh.noronha@gmail.com wrote:
> K&R states that the right operand must be non-negative.
>
> "The shift operators << and >> perform left and rig...

**Integer left shift operation**Hi all,
I got an syntax error with the following left shfit operation assignment.
# Assignment target incompatible with right side. Expected type
"INTEGER".
# Cannot find function to_integer for these actuals.
# Undefined type of expression.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.al
process
variable ip1, nprev: integer;
begin
nprev:=20;
ip1:=to_integer(to_StdLogicVector(nprev) sll 1);
end process;
Any help will be very appreciate!!!
Kindest regards,
Stanley
cltsaig a �crit:
> Hi all,
>
> I got an syntax error wit...

**index manipulation... shifting and rotating**I know there are functions like rot90 to rotate a matrix about a point, but you need the the matrix. I only have the linear index values of the matrix. I can easily shift the indexes by adding or subtracting either row or column values... but what if I wanted to rotate by 90 or 180 degrees... is this possible with just the index values?
-one idea I had was to progressively subtract (or add depending on which way I want to shift) more from each row index, but I don't have them in a specific order to implement this progressive shift.
here is a small example:
A = [ 11 22 33 44 55; ...

**how to shift and rotate a matrix**There must be an easy way to do this...
I need to shift and rotate a matrix
i.e.
if I start with matrix ...
1 2 3
4 5 6
7 8 9
i'd like to specify how many elements to shift by.. i.e.
shift by 2
8 9 1
2 3 4
5 6 7
i tried circshift but now what i want.
Is there a command that will do this?
Txs in advance
-dave
"magda magdaleno" <d.a.magdaleno@gmail.com> wrote in message <hurr3i$3jq$1@fred.mathworks.com>...
>
> if I start with matrix ...
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> i'd like to specify how ma...

**Is there a logic shift operator in C++?**Dear all,
Is there a logic shift operator in C++? I tried ">>", it is an
arithmetic shift operator.
Thanks!
-Andy
<yuyang08@gmail.com> wrote:
>Dear all,
>Is there a logic shift operator in C++? I tried ">>", it is an
>arithmetic shift operator.
No, there is no built-in logical shift right.
Steve
Steve Pope posted:
>>Is there a logic shift operator in C++? I tried ">>", it is an
>>arithmetic shift operator.
As far as I know, it's implementation-defined as to whether it's logical
shift or arithm...