PC Review


Reply
Thread Tools Rate Thread

C# equivlanet of Java's unsigned right shift operator (>>>)

 
 
almurph@altavista.com
Guest
Posts: n/a
 
      27th Jun 2011
Hi Folks,

Quick one. I am doing some reverse engineering of some Java and
have come accross the following Java code:

/* Java */
int c = (a + b) >>> 1;

I want to reverse engineer it. Here is my equivalent. Comments/
suggestions much appreciated:

/* C# reverse enginner attempt */

int c = (int)(((uint)(a + b)) >> 1)


Once again comments/suggestions/improvements are appreciated...
Colm
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      28th Jun 2011
On 6/27/2011 1:44 PM, (E-Mail Removed) wrote:
> Quick one. I am doing some reverse engineering of some Java and
> have come accross the following Java code:
>
> /* Java */
> int c = (a + b)>>> 1;
>
> I want to reverse engineer it. Here is my equivalent. Comments/
> suggestions much appreciated:
>
> /* C# reverse enginner attempt */
>
> int c = (int)(((uint)(a + b))>> 1)
>
>
> Once again comments/suggestions/improvements are appreciated...


It is one way.

You could also use:

int c = (a + b) >> 1;
if(c < 0) c += 0x80000000;

or:

int c = 0x7FFFFFFF & ((a + b) >> 1);

Arne

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shift Bits of Unsigned Int Marty McFly Microsoft VB .NET 7 19th Jul 2004 04:28 AM
unresolved external symbol "void * __cdecl operator new(unsigned int) =?Utf-8?B?Q1A=?= Microsoft VC .NET 1 23rd Mar 2004 12:39 AM
Java Permissions - Unsigned Content Richard M. Microsoft Windows 2000 Registry Archive 0 19th Nov 2003 04:19 PM
Java Permissions - Unsigned Content Richard M. Microsoft Windows 2000 Registry 0 19th Nov 2003 04:19 PM
Unsigned Right Shift Operator (>>>) Bill Microsoft C# .NET 2 11th Aug 2003 04:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:35 AM.