f

#### shift right arithmetic

```is there an equivalent way in verilog to do this:

The contents of the low-order 32-bit word of a number are shifted
right, duplicating the sign-bit (bit 31) in the emptied
bits
```
 0
rekz
3/8/2010 12:03:54 AM
comp.lang.verilog 3837 articles. 2 followers.

7 Replies
797 Views

Similar Articles

[PageSpeed] 5

```It's so easy that I'm not sure I understand your meaning right.

@clk
reg A[31:0]= {A[31],A[31:1]}

> is there an equivalent way in verilog to do this:
>
> The contents of the low-order 32-bit word of a number are shifted
> right, duplicating the sign-bit (bit 31) in the emptied
> bits

```
 0
Shenzhi
3/8/2010 4:06:34 AM
```rekz wrote:
> is there an equivalent way in verilog to do this:
>
> The contents of the low-order 32-bit word of a number are shifted
> right, duplicating the sign-bit (bit 31) in the emptied
> bits

Are you looking for the >>> operator? In reality there are many ways to
do this. The >>> operator only works if the value is signed. For
unsigned values you need to either cast it signed or resort to bit
manipulation like the previous poster showed.

Cary
```
 0
Cary
3/8/2010 7:54:35 AM
```On Sun, 07 Mar 2010 23:54:35 -0800, "Cary R." wrote:

>The >>> operator only works if the value is signed.

Let's try again.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The >>> operator gives sign-extended shift only
if it is used in a signed EXPRESSION.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The signedness of its argument is not the whole
story.  (Cary, I'm sure you are perfectly aware
of that.  But it is a HUGE pitfall for novices
and I make no apology for raising it again.)

A few examples, in the form of a quiz -

reg signed [7:0] S1;
reg signed [7:0] S2;
reg [7:0] U1; // unsigned
reg [7:0] U2; // unsigned

For each of the following examples, decide whether
the >>> operator does sign-extended (signed) or
zero-fill (unsigned) shifting:

initial begin
... <assume we have sensible values in the variables> ...
S2 = S1 >>> 3;         // example 1
U1 = S1 >>> 3;         // example 2
S2 = U1 + (S1 >>> 3);  // example 3
U1 = S2 + (S1 >>> 3);  // example 4
S2 = S1 >>> U1;        // example 5
S2 = \$signed(U1 >>> 3);  // example 6
S2 = U1 + \$signed(S1 >>> 3);  // example 7
S2 = U1 + \$unsigned(S1 >>> 3);  // example 8
S2 = S1[7:0] >>> 3;    // example 9
end

(soon)

(just a few more lines down)

S2 = S1 >>> 3;         // example 1
signed shift (all operands are signed)

U1 = S1 >>> 3;         // example 2
signed shift (signing of assignment target
doesn't affect signedness of expression)

S2 = U1 + (S1 >>> 3);  // example 3
UNSIGNED shift (operand U1 is unsigned, forces
the whole expression to be unsigned despite S1)

U1 = S2 + (S1 >>> 3);  // example 4
signed shift (again U1 doesn't affect signing)

S2 = S1 >>> U1;        // example 5
signed shift (unsigned shift count doesn't
affect the signed expression context)

S2 = \$signed(U1 >>> 3);  // example 6
UNSIGNED shift (\$signed creates a signed
result, but does not affect the signing of its
argument expression)

S2 = U1 + \$signed(S1 >>> 3);  // example 7
signed shift (\$signed, or ANY function, protects
its argument expression from the unsigned context)

S2 = U1 + \$unsigned(S1 >>> 3);  // example 8
signed shift (\$unsigned does not affect the signing
of its argument expression)

S2 = S1[7:0] >>> 3;    // example 9
UNSIGNED shift (a part select is invariably unsigned)

Glad we got that cleared up...
--
Jonathan Bromley
```
 0
Jonathan
3/8/2010 10:29:14 AM
```On Mar 8, 3:29=A0am, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
> On Sun, 07 Mar 2010 23:54:35 -0800, "Cary R." wrote:
> >The >>> operator only works if the value is signed.
>
> WHOAH! =A0How many times have I ranted about this...?
>
> Let's try again.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> The >>> operator gives sign-extended shift only
> if it is used in a signed EXPRESSION. =A0
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The signedness of its argument is not the whole
> story. =A0(Cary, I'm sure you are perfectly aware
> of that. =A0But it is a HUGE pitfall for novices
> and I make no apology for raising it again.)
>
> A few examples, in the form of a quiz -
>
> =A0 reg signed [7:0] S1;
> =A0 reg signed [7:0] S2;
> =A0 reg [7:0] U1; // unsigned
> =A0 reg [7:0] U2; // unsigned
>
> For each of the following examples, decide whether
> the >>> operator does sign-extended (signed) or
> zero-fill (unsigned) shifting:
>
> initial begin
> =A0 ... <assume we have sensible values in the variables> ...
> =A0 S2 =3D S1 >>> 3; =A0 =A0 =A0 =A0 // example 1
> =A0 U1 =3D S1 >>> 3; =A0 =A0 =A0 =A0 // example 2
> =A0 S2 =3D U1 + (S1 >>> 3); =A0// example 3
> =A0 U1 =3D S2 + (S1 >>> 3); =A0// example 4
> =A0 S2 =3D S1 >>> U1; =A0 =A0 =A0 =A0// example 5
> =A0 S2 =3D \$signed(U1 >>> 3); =A0// example 6
> =A0 S2 =3D U1 + \$signed(S1 >>> 3); =A0// example 7
> =A0 S2 =3D U1 + \$unsigned(S1 >>> 3); =A0// example 8
> =A0 S2 =3D S1[7:0] >>> 3; =A0 =A0// example 9
> end
>
>
> (soon)
>
> (just a few more lines down)
>
> =A0 S2 =3D S1 >>> 3; =A0 =A0 =A0 =A0 // example 1
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (all operands are signed)
>
> =A0 U1 =3D S1 >>> 3; =A0 =A0 =A0 =A0 // example 2
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (signing of assignment target
> =A0 =A0 =A0 =A0 =A0 =A0doesn't affect signedness of expression)
>
> =A0 S2 =3D U1 + (S1 >>> 3); =A0// example 3
> =A0 =A0 =A0 =A0 =A0 =A0UNSIGNED shift (operand U1 is unsigned, forces
> =A0 =A0 =A0 =A0 =A0 =A0the whole expression to be unsigned despite S1)
>
> =A0 U1 =3D S2 + (S1 >>> 3); =A0// example 4
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (again U1 doesn't affect signing)
>
> =A0 S2 =3D S1 >>> U1; =A0 =A0 =A0 =A0// example 5
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (unsigned shift count doesn't
> =A0 =A0 =A0 =A0 =A0 =A0affect the signed expression context)
>
> =A0 S2 =3D \$signed(U1 >>> 3); =A0// example 6
> =A0 =A0 =A0 =A0 =A0 =A0UNSIGNED shift (\$signed creates a signed
> =A0 =A0 =A0 =A0 =A0 =A0result, but does not affect the signing of its
> =A0 =A0 =A0 =A0 =A0 =A0argument expression)
>
> =A0 S2 =3D U1 + \$signed(S1 >>> 3); =A0// example 7
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (\$signed, or ANY function, protects
> =A0 =A0 =A0 =A0 =A0 =A0its argument expression from the unsigned context)
>
> =A0 S2 =3D U1 + \$unsigned(S1 >>> 3); =A0// example 8
> =A0 =A0 =A0 =A0 =A0 =A0signed shift (\$unsigned does not affect the signin=
g
> =A0 =A0 =A0 =A0 =A0 =A0of its argument expression)
>
> =A0 S2 =3D S1[7:0] >>> 3; =A0 =A0// example 9
> =A0 =A0 =A0 =A0 =A0 =A0UNSIGNED shift (a part select is invariably unsign=
ed)
>
> Glad we got that cleared up...
> --
> Jonathan Bromley

wait is there a >>> operation in verilog? lol.. didn't know about
that... that's what I've been looking for
```
 0
rekz
3/8/2010 2:35:48 PM
```On Mon, 8 Mar 2010 06:35:48 -0800 (PST), rekz wrote:

>wait is there a >>> operation in verilog?

Yup, it's been there since 2001.

You did *read* the rest of my post, right?  So you
know how >>> can rather easily turn around and
bite you in the arse?  'coz if you don't know those
things, you will end up with a very sore backside.

amicalement
--
Jonathan Bromley
```
 0
Jonathan
3/8/2010 9:18:04 PM
```On Mar 8, 2:18=A0pm, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
> On Mon, 8 Mar 2010 06:35:48 -0800 (PST), rekz wrote:
> >wait is there a >>> operation in verilog?
>
> Yup, it's been there since 2001.
>
> You did *read* the rest of my post, right? =A0So you
> know how >>> can rather easily turn around and
> bite you in the arse? =A0'coz if you don't know those
> things, you will end up with a very sore backside.
>
> amicalement
> --
> Jonathan Bromley

Yes I did read your post... I think I'll avoid using the >>> then...
as the result needs to be stored in a signed variable right for this
to make it happen? While my result should be stored in a reg[31:0]
Result
```
 0
rekz
3/9/2010 3:20:54 PM
```Jonathan Bromley wrote:

> The signedness of its argument is not the whole
> story.  (Cary, I'm sure you are perfectly aware
> of that.  But it is a HUGE pitfall for novices
> and I make no apology for raising it again.)

Yes I probably should have said value/expression and yes I know exactly
how this works, I have two of them in the RTL for the chip we just
shipped. You also need to understand this was at the end of a 15 hour
day and my average days had not been that much shorter, so my thought
was probably a bit scattered.

For some more fun add the following after example 4 (concatenation).
S2 = U1 + {S1 >>> 3};
U1 = S2 + {S1 >>> 3};

Cary
```
 0
Cary
3/10/2010 6:56:58 PM

Similar Artilces:

Behavior of Arithmetic Right Shift For Verilog 2001
Hi all, I'm seeing some mismatching results for a Verilog 2001 arithmetic shift operator in NCVerilog and since I don't have a Verilog 2001 LRM handy, I thought I'd ask to experts to see if they knew what the LRM specified in this regards. I originally found this when we had an RTL/gates simulation mismatch, but have extracted the problem to the following Verilog code: module ArithmeticShiftTest; reg signed [31:0] in; reg [5:0] shift; reg signed [31:0] out; //calculate arithmetic barrel shift right always@(*) out = in >>> shift; initial begin //set up inputs for always block in = 32'sh80000000;//set to highest value negative number(-2147483648) shift = 6'd32; //shift the entire width of the word #1; //allow time for inputs to propagate //check output if(out === (32'sh80000000 >>> 6'd32)) begin \$display("PASS: 32'sh80000000 >>> 6'd32 = 0x%h", in, shift, out); end else begin \$display("FAIL: 32'sh80000000 >>> 6'd32 != 0x%h,", (32'sh80000000 >>> 6'd32), " actual = 0x%h.", out); end end // initial begin endmodule // ArithmeticShiftTest When I simulate with ncverilog (version 5.3-s005) I get the following message: FAIL: 32'sh80000000 >>> 6'd32 != 0xffffffff, actual = 0x00000000. So in other words, the output...

problem with verilog-in in when using arithmetic shift in verilog vode.
Hello everyone, when I using verilog-in in ic5141,it appears a sytanx error ">>> error". my verilog code have arithmetic shift >>> adn <<<,which is the new characteristic of verilog-2001. and I do verilog-in operation in behavior RTL,my question is :how to fix this error?and still:does ic5141 verilog-in function support verilog2001 verison's arithemetic shift operationor ">>>" and "<<<" ? thank you. On 8 13 , 1 09 , ponderboy <cqu_...@yahoo.com.cn> wrote: could anybody help me please. > He...

Skybuck presents ShiftLeft( Left, Right, Shift ) and ShiftRight( Right, Left, Shift )
Hello, I think these two functions will come in very handy to solving the "write longword bits" problem. ShiftLeft( Left, Right, Shift ) ShiftRight( Right, Left, Shift ) Shifting with extra inputs is what is required to solve it nicely. // Begin of Code *** program Project1; {\$APPTYPE CONSOLE} { Skybuck presents ShiftLeft( Left, Right, Shift ) and ShiftRight( Right, Left, Shift ) version 0.01 created on 5 may 2008 by Skybuck Flying. Be carefull though, the shift parameter must be 0 to 31. } uses SysUtils; // make overloaded versions for easy coding // display in big e...

Matlab arithmetic bit shifting right
Does anybody know how to perform an arithmetic bit shift right in Matlab? I tried using bitshift, but it cuts off the decimal points (i.e. bitshift(6.625,-2) = 1, but it should be 1.75). I have also tried to get the binary number using the bitget function, but it too cuts off the decimal points and returns (1100 or 6). Thanks in advance. "John Ryan" <jballgame20@aol.com> writes: > Does anybody know how to perform an arithmetic bit shift right in > Matlab? I tried using bitshift, but it cuts off the decimal points > (i.e. bitshift(6.625,-2) = 1, but it should be 1.75). I have also > tried to get the binary number using the bitget function, but it too > cuts off the decimal points and returns (1100 or 6). Thanks in > advance. The bit*** functions assume "flints", or integers represented as floating point values. What binary value do you think you should get for 6.625? -- Peter Boettcher <boettcher@ll.mit.edu> MIT Lincoln Laboratory MATLAB FAQ: http://www.mit.edu/~pwb/cssm/ Also, starting in version MATLAB 6.5 (Release 13) non-flint inputs to bitshift actually error: >> bitshift(6.625,-2) ??? Error using ==> bitshift Inputs must be integers. whereas before it would have silently truncated 6.625 to 6. Penny Anderson The MathWorks, Inc. "Peter Boettcher" <boettcher@ll.mit.edu> wrote in message news:m3zn8lp9jd.fsf@coyote.llan.ll.mit.edu... > "John Ryan" <jballgame20@aol.com> wri...

shift left, shift right
Hello, Is there any command to shift left or right a vector ? thanks for your reply. patrice: <SNIP ...Is there any command to shift left or right a vector... a hint: help circshift us Try these: 4.1 Vectors To shift and rotate the elements of a vector, use X([ end 1:end-1 ]); % shift right/down 1 element X([ end-k+1:end 1:end-k ]); % shift right/down k elements X([ 2:end 1 ]); % shift left/up 1 element X([ k+1:end 1:k ]); % shift left/up k elements Try this link: <http://www.cs.huji.ac.il/course/2003/impr/matlab/MatlabTip.pdf> -TRO patrice wrote: > > > H...

Question about arithmetic right shift with sign extension
I understand Verilog 2001 added the ">>>" operator for sign extension right shift. But how does it work? I was implementing a shifter unit as part of an ALU. I had done the following: assign #1 rarithmetic = b >>> shiftamount; where b and shiftamount were both input [31:0] vectors. However, the sign extension does not occur. I had b = 0xd1200000 and the result was 0x0000d120 instead of 0xffffd120. I know there is also the "signed" keyword but it didn't seem to have any effect when I tried "input signed [31:0] ...". What am I doing wrong? Would synthesis results be different if "signed" keyword is used? In the end, I just end up coding up a variable 32 bit sign extension shifter as shown below. Is there a better/more compact way to do the same thing? I'd like to keep it synthesizable if possible. Thanks for any help. Kind regards. /* * 32-bit sign extend shifter */ module signextshifter32(/*AUTOARG*/ // Outputs y, // Inputs a, shiftamt ); input [31:0] a; // input input [4:0] shiftamt; // shift amount output [31:0] y; // output assign #1 y = (shiftamt == 5'b00000) ? {a[31:0]} : (shiftamt == 5'b00001) ? {{1{a[31]}}, a[31:1]} : (shiftamt == 5'b00010) ? {{2{a[31]}}, a[31:2]} : (shiftamt == 5'b00011) ? {{3{a[31]}}, a[31:3]} : (shiftamt == 5'...

what does SHIFT-left-or-right of up-down-left-right do?
Well, I know about shift up-and-down: shift-right ("red" or whatever) up and down on choose-box, HIST, things like that, take the cursor all the way to the beginning or the end. shift-left ("white") on up and down scroll the screen-full up or down (the FIRST such click *stupidly* goes to the final CURRENTLY-ON-SCREEN choice or whatever (meaning TWO double-button-pushes to scroll-down that FIRST time.) What are some of the OTHER possibilities, ie with the left and right arrows? Oh, apparantely undocumented, I've found (via mistaken key-pushes) that RIGHT-arrow will do a SWAP (on stack), and that an UP-arrow gets you into HIST (that HIST is *one nice feature*!) Other tricks with those arrows? Thanks! David David Combs wrote: > Well, I know about shift up-and-down: > > shift-right ("red" or whatever) up and down on > choose-box, HIST, things like that, take the > cursor all the way to the beginning or the end. > > shift-left ("white") on up and down scroll the > screen-full up or down (the FIRST such click > *stupidly* goes to the final CURRENTLY-ON-SCREEN > choice or whatever (meaning TWO double-button-pushes > to scroll-down that FIRST time.) > > > What are some of the OTHER possibilities, ie with the > left and right arrows? > > > Oh, apparantely undocumented,...

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 */ > ...

left shift then right shift an unsigned int
Hello, for the following code: unsigned int var = 0xFF2277F0UL; unsigned char take2 = (var << 8) >> 24; Is there any pitfall about the shift? (get '22' i.e. 34 or '"' as wanted) Thanks and best regards, Wenjie On 11 Jul 2003 04:07:43 -0700, gokkog@yahoo.com (Wenjie) wrote: >Hello, for the following code: > unsigned int var = 0xFF2277F0UL; > unsigned char take2 = (var << 8) >> 24; >Is there any pitfall about the shift? (get '22' i.e. 34 or '"' as wanted) It looks OK to me... -- Bob Hairg...

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 shifted left. Example if N=11101101 [binary value] will become: 111011010 when shiftby=1; will become: 1110110100 when shiftby=2; will become: 11101101000 when shiftby=3; will become: 111011010000 when shiftby=4; will become: 1110110100000 when shiftby=5; will become: 11101101000000 when shiftby=6; will become: 111011010000000 when shiftby=7; I have to use use left shift and right shift to shift Number right/ left depending on value of shiftby if (shift>0) output = N >> shiftby; else output = N << (-shiftby);// working but inefficient. I am using above shift operator many times. I want to get rid of the if then else condition. As If condition takes a lot of time. I want something like output = N >> shiftby; where N is shifted left / right automatically if shiftby is -ve then shift left otherwise shift right. I tried using below function divider=2^shiftby; /...

Distinguish Shift - click left and Shift
Is there a way to distinguish the SelectionType property in a figure for a Shift - click left and Shift - click right? Both result in the SelectionType 'Extend'... Thx "Stefan" <s@m.de> wrote in message <hpkik9\$5c3\$1@fred.mathworks.com>... > Is there a way to distinguish the SelectionType property in a figure for a Shift - click left and Shift - click right? > Both result in the SelectionType 'Extend'... > > Thx Hi Stefan, if you are in a callback function you can use this example with small changes, taken from the figure prope...

how to locate right slot in a range with right-shifting and offset?
Hi all, Assume I non-uniformally break down a range from 0 to (2^10)-1 into (2^4)-1 blocks. |----|---|------|---|......|--| 0 5 7 (2^10)-1 For a given value x (x may be from 0 to 2^10-1), I would like to locate what block x should be in. For example if x is 6, I want to find the second block (from 5 to 7) in the above figure. ( x is integers). In a technical report, for this task, I see they use the operator: block_address=x >> shift_amount + offset_amount. (>> is right shift). where shift_amount and offset_amount are the same for all values of x. (all ...

right shifting
if I have the foolowing code, main() { unsigned int i=34; i>>=32; } why does the value of i remain 34? I thought it should be a zero. (the g++ compiler gives me a warning about shifting >= size of variable.) crookie wrote: > if I have the foolowing code, > > main() > { > unsigned int i=34; > i>>=32; > } > > why does the value of i remain 34? I thought it should be a zero. > (the g++ compiler gives me a warning about shifting >= size of variable.) The standard [5.8/1] says about the shift operators: [...] The behavior is undefined if th...

Right Shift
Here's some confusion for you... <?PHP \$x = (4653896912 >> 13); echo \$x; ?> I ran that on two different servers. Server A gave me: 43814 Server B gave me: 568102 I have been hacking away and researching this for hours. I am completely clueless. Any suggestions or workarounds? Thanks in advance. I just figured out that server A is a 32 bit machine and server B is 64. How can I account for this? CrashRoX said the following on 15/03/2006 10:32: > Here's some confusion for you... > > <?PHP > \$x = (4653896912 >> 13); > echo \$x; > ?> > ...

right shifting
if I have the foolowing code, main() { unsigned int i=34; i>>=32; } why does the value of i remain 34? I thought it should be a zero. (the gcc compiler gives me a warning.) In article <1163114704.824290@sj-nntpcache-1.cisco.com>, crookie <noob@nairco.com> wrote: >if I have the foolowing code, >main() >{ >unsigned int i=34; >i>>=32; >} >why does the value of i remain 34? I thought it should be a zero. >(the gcc compiler gives me a warning.) Because the standard says so. C89 3.3.7 Bitwise Shift Operators If the value of the right oper...

shift arithmetic
hello every one in modelsim 10.0c i wrote >>> i mean shift arithmetic but the modelsim doesn't know. the second and third > are blue but the first > is black help me how can write shift arithmetic in modelsim. thanks Hi A.H.E.J. > i mean shift arithmetic but the modelsim doesn't know. It is not a tool matter but a language matter. I can help you but holistically not specifically. Can you send me a description of the entire problem? Please note that >>> denotes right rotation in some offshoot C-like languag= es. In Verilog there are 2 ...

How to do >>(right shift) and <<(left shift) in Matlab?
Hi all, How >>(right shift) and <<(left shift) 2'complement number (both positive and negative integer). Is x>>2 equal to floor(x/4)? And is x<<2 equal to x*4? Best regards, Davy Soho wrote: > Hi all, > > How >>(right shift) and <<(left shift) 2'complement number > (both positive and negative integer). > > Is x>>2 equal to floor(x/4)? > > And is x<<2 equal to x*4? > > Best regards, > Davy > Does bitshift: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bitshift.html do what you wa...

how to avoid right shifting
i have an incremental historgram package where i have to keep the array buckets sorted. each bucket.value is the number of times a value fell near bucket.key since the array is sorted, i can do a O(log(N)) binchop to find a bucket but sometimes, i am forced into an O(N) operation that i want to avoid. as i read in input numbers, if one bucket gets too big, i split it dividing the old buckt.value in two. then i add the new number into one of the two halves (depending on which on it is closest to) thing is, after the split, the array is now one larger so i move everything to thr right for(...

Injected Right Shift
My application currently does keyboard injection and everything works... except for the right shift key. I don't know why, the other right-modifier keys all work but right shift key doesn't go through. MapVirtualKey returns 0 when I try to map 0x36 (the scancode for right shift) and if I manually set the wVk to VK_RSHIFT it ends up getting changed to 0 sometime before my low level keyboard hook captures it (the OS is removing the VK) but the scancode stays as 0x36. I have searched everywhere for an answer but have been unable to find anything. Does anyone know what the trick ...

right shifting to divide
Hi, I am reading 'Lion's Commentary on UNIX', and I am wondering about a small bit of code, which is as follows: /* * Return the arg/128 rounded up. */ nseg(n) { return((n+127)>>7); } It is found on sheet 16 beginning at line 1768, for anyone who might have the book. Anyway, I curious as to the adding of 127 to the number, and then the right shift. I realise that it divides the number roughly by two, but I am still kind of foggy as to the methodology. Why add 127 then right shift by 7? Why not just right shift by 1? Rob Somers Rob Somers wrote: > Hi, I am rea...

Shift left arithmetic?
I was looking up the shift operator in VHDL since I seldom use it and saw that there is both a shift left logical and a shift left arithmetic. The logic shift left shifts in zeros and the arithmetic shift left shifts in the value of the lsb. I remember from school how a shift right can be logical or arithmetic in order to implement signed and unsigned arithmetic. But when shifting left, I have always used a single shift operator, the logical shift. If an arithmetic left shift is used, it gives a valid result for some values, assuming that the "valid" result is the same as multipl...

Shift + Right Click
Is there any way to monitor for a Shift + Right Click in Matlab? This isn't an option in the Selection Type property of figures, but I'm hoping for an easy way to determine if there was a Shift + Right Click. If not there's always Ctrl + Left Click I suppose... ...

Shifting data to the right
Access97 using VBA code. I have an array of textboxes, 8 columns across and 5 rows down. If all the boxes in row 3 have data in them and I place my cursor in the 4th box in this row, how can I move the contents of 4 to 5 then 5 to 6, 6 to 7, and 7 to 8. I don't want to effect rows above and below row 3. All I want to do is push data to the right making room to insert an item to a lineup. My textboxes are named txt01 thru txt40 Each row represents a different machine lineup. I've looked at select case using Case txt17 to txt24 then breaking it into if txt17 if txt18 etc. This looks bulk...

right-shifting problem
Hi, I want to combine 2 different bytes into an integer, so that 1 byte will be to the left of the second byte. example: byte[2] b; b[0] = 0xE5; b[1] = 0x35; I want to get the unsigned number of 0xE535 (=58677), so I did: int num = (b[0] << 8) | b[1]; But I got the negative number -6859. How can I get the desired result (58677)? -thanks, Eli Found the solution: ;-) int num = (((int)b[0] & 0xFF) << 8) | ((int)b[1] & 0xFF) On 17 Dec 2005 22:14:46 -0800, eli.hen@gmail.com wrote, quoted or indirectly quoted someone who said : >example: > byte[2]...

Web resources about - shift right arithmetic - comp.lang.verilog

Arithmetic - Wikipedia, the free encyclopedia
... of numbers , especially the properties of the traditional operations between them— addition , subtraction , multiplication and division . Arithmetic ...

Arithmetic - Wikipedia, the free encyclopedia
... numbers , especially the properties of the traditional operations between them — addition , subtraction , multiplication and division . Arithmetic ...

Mental Arithmetic - train your brain! on the App Store on iTunes
Get Mental Arithmetic - train your brain! on the App Store. See screenshots and ratings, and read customer reviews.

Arithmetic Puzzle - Haskell live coding - YouTube
Live coding of Ruby Quiz 7 - Arithmetic Puzzle "Countdown" Unscripted, unedited, (uncut) - Haskell Uncut Read more at my blog post: http://c ...

Australia's deadliest sniper, Ian Robertson, 'never did the arithmetic'
The deadliest man in Australia comes from Melbourne, but he is not a gangster or a hitman. He is more a foxtrotting man, these days. He can do ...

Genetic anomaly could explain severe difficulty with arithmetic - The Science Show - ABC Radio National ...
... is that numbers are wired into the human brain and perhaps a genetic anomaly explains why some children have severe difficulties with arithmetic. ...