473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C# equality to Java >>> operator


Hi.
Is there a C# operator that is equal to the java operator:


Regards
Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
2 1950
I think >>> was added to Java as a bit of a hack because they didn't
have any unsigned numbers. C# does support unsigned numbers like uint.
So if your intent is to shift right without extending sign bit. use uint
or ulong data types.

Hope this helps
Leon Lambert

Dennis Myrén wrote:
Hi.
Is there a C# operator that is equal to the java operator:
Regards
Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 15 '05 #2
Dennis,

From the java language specification, it says:

The value of n>>>s is n right-shifted s bit positions with zero-extension.
If n is positive, then the result is the same as that of n>>s; if n is
negative, the result is equal to that of the expression (n>>s)+(2<<~s) if
the type of the left-hand operand is int

So, if you have an integer in a variable n, you can do this:

// First, shift over two bits.
int pintResult = n >> s;

// Now, if it is negative, perform an additional operation.
if (pintResult < 0)
// Modify.
pintResult += (2 << ~s);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Dennis Myrén" <de**********@greydigital.no> wrote in message
news:Oh****************@TK2MSFTNGP10.phx.gbl...

Hi.
Is there a C# operator that is equal to the java operator:


Regards
Dennis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #3

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

Similar topics

1
by: TI | last post by:
Where would you start if you wanted to program perhaps a java application to enable a bluetooth mobile phone to work as walkie-talkie? ( schematics, compilers... ) thanks
5
by: Mike | last post by:
I need to provide an example to upper management on how this works, but I don't have the time to write one. Does someone already have some code (java and c/vc/vc++) that demonstrates java using...
9
by: Henrik | last post by:
In Java you can write something like this. Does anyone know how to do this in javascript? "byte b=Integer.parseInt(int value or String).byteValue;"
10
by: Ole | last post by:
Goodday everybody, i want to create an array that represents data, that has to be transferred to a pdf doc ( iTextSharp ). The problem is, that i seem too loose my faith. Namely, ( i have...
3
by: Richard A. Lowe | last post by:
Hi all (sorry I haven't been around lately for those who know me, life happens :) I have to call a native DLL (written > 5 years ago, not by me, and all source lost) that is currently being...
0
by: almurph | last post by:
Hi, Hope you can help me here and apologies if I'm in the wrong board! We have a web service behind a firewall that we want our customers to be able to connect to. Said Webservcie is coded in...
5
by: ma740988 | last post by:
Consider: #include <iostream> #include <sstream> #include <string> int main ( ) { { double pi = 3.141592653589793238; std::stringstream a;
7
by: William S Fulton | last post by:
I'm looking for the name of the following casting style in order to do some reading around on it and why it is sometimes used. unsigned long long ull = 0; void * ptr = 0; ull = *(unsigned...
6
N002213F
by: N002213F | last post by:
I have a Java text reader program that can easily read small text, but seems fails to read larger files >20MB. It seems to truncate the contents it reads. I there a way of making sure all the data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.