views:

219

answers:

3
+1  Q: 

ushort equivalent

I have an application in C# that I'm trying to convert to java. The C# app has a few variables that are of type ushort. Is there an equivalent in java?

Thank you

+3  A: 

The closest equivalent in terms of size is char, since Java doesn't have unsigned types, but it's overloaded in Java to provide additional semantics related to individual characters. In general, just pick the next largest integral type (int, in this case). (You're not the only one who wants it, though.)

John Feminella
+2  A: 

Have a look at this article: http://www.darksleep.com/player/JavaAndUnsignedTypes.html

Maximilian Mayerl
+1  A: 

As you may be aware, Java has no unsigned numbers. This means you're going to have to go with another solution. It's generally easiest to just use the next larger type in cases like these, such as int (which is simply a 32-bit signed integer).

unwind