Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I want to use unsigned int in java, how can i use?
Posted

Java has not unsigned int. Depending of your needs you may find some workarounds "What is the Java equivalent of unsigned?" page[^].
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Oct-12 16:29pm    
Good catch! And good article to get the explanations as well. My 5.
I personally think that not having some types like uint (not via "unsigned" keyword, of course) is a shame. Unsigned types are heavily under-used, even though they are very important, useful and simple.
--SA
CPallini 1-Oct-12 16:46pm    
Thank you. Recently I read some criticism of unsigned datatypes (because they are often misused, etc..), unfortunately I have no link.
Sergey Alexandrovich Kryukov 1-Oct-12 17:20pm    
You are welcome. Good answer anyway.
Criticism? Aha, "because it's hard to understand the difference"? or "hard to predict how a variable will be used"? or "because -1 can be used as "not found""? :-)
Or something a bit more serious, which I cannot believe could be there? Would be interesting to see though... :-)
--SA
pasztorpisti 1-Oct-12 17:43pm    
You are right, enough time spent in the industry shows you when to use int or uint. But be careful, not every piece of library is written by an architect! :-) Sometimes there is not other choice then using a shamefully bad library written by some clowns to access a service. ;-) When its about integration with legacy stuff I think unsigned types are necessary sometimes, but java showed me that you can leave without uints pretty well if the sorrounding libraries are built without uint.
Sergey Alexandrovich Kryukov 1-Oct-12 18:28pm    
Good points, appreciate them. And I even have a pretty good idea where those clowns come from; I saw more their dances with the tambourine (or, were they shamans? no matter :-) than I would like to see. :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900