473,657 Members | 2,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unsigned Right Shift Operator (>>>)

I am trying to convert a Java APP to C# and it appears C# does not have a
operator. Does anyone the best way to conver this operator in to c#?


Thanks.

--
Bill
Nov 15 '05 #1
2 12900
Cast the variable to unsigned.

e.g. if it is a "long":

unsigned long result = ((unsigned long)myVariable ) >> myShift;

BTW I have got so used to the new C++ style of casting, where the variable
goes inside brackets and you therefore know unequivocally the scope of the
cast, that I can't imagine why C# uses the old C-style casts.

S.

"Bill" <ms****@hotmail .com> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to convert a Java APP to C# and it appears C# does not have a
operator. Does anyone the best way to conver this operator in to c#?


Thanks.

--
Bill

Nov 15 '05 #2
PS... perhaps you should be using an unsigned type in the first place?

S.

"Bill" <ms****@hotmail .com> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to convert a Java APP to C# and it appears C# does not have a
operator. Does anyone the best way to conver this operator in to c#?


Thanks.

--
Bill

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3028
by: Peter Bromley | last post by:
The following code snippet does not seem to work correcly unsigned __int64 result = 0xFFFFFFFFFFFFFFFF; result = result << 64; Debugger.WriteLine(System::String::Format(S"{0:X16}", __box(result)); result = 0xFFFFFFFFFFFFFFFF; result = result >> 64; Debugger.WriteLine(System::String::Format(S"{0:X16}", __box(result)); __int64 result = -1;
7
2905
by: Marty McFly | last post by:
Hello VB Gurus, I have an unusual requirement to shift an unsigned int right one bit: Dim myVar As UInt32 = UInt32.Parse("123456") Dim myResult As UInt32 myResult = myVar >> 1 However, the >> operator only works on Byte, Short, Integer, and Long.
3
4305
by: Bob | last post by:
What is an equivalent of a Right Shift operator (>>) in visual basic 6.0? I am trying to convert a C++ code into visual basic that looks like the following: While (m < n) { k = (m+n) >> 1 } Thanks,
5
4512
by: Schüle Daniel | last post by:
Hello Newsgroup, I was thinking about integer literals and what default types they get and how they behave when applied to shift operator assume sizeof(int) == sizeof(unsigend int) = 4 int ii = -1024; cout << (ii>>1) << endl; // -512
6
2346
by: NM | last post by:
I am given an int and have to tell whether the bit representation of that int is a palindrome or not. Here is what I have come up with bool isIntPalindrome(int num) { unsigned int temp = num; int reversed = 0; while (num != 0) {
4
15343
by: techie | last post by:
I have defined a number of unsigned integer types as follows: typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedfe long long uint64; Is it necessary to explicitly cast from one type of unsigned integer type to another even though they do so implicitly?
6
5632
by: Bobrick | last post by:
Hi. Thanks to everyone who replied to my last post, it turns out it wasn't the line where I was trying to treat the variable in question as an array which was the problem, but the line above. char temp; std::vector<unsigned charmmessage; while (!done){
10
10688
by: krunalb | last post by:
Hi, I am trying to shift unsigned long long value by 64 bits and this is what i get #include <stdio.h> int main() { unsigned short shiftby= 64;
2
2971
by: gaya3 | last post by:
Hi, can anyone explain the unsigned right shift operator with example? And also why there is no unsigned left shift operator? is there any specific reason for that? -Thanks & regards, Hamsa
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.