Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

questions about int in java...

Thread view: 
Mark Haase - 31 Mar 2004 08:22 GMT
1) Does int have a consistent size across platforms?
2) My IDE doesn't recognize the "unsigned" keyword. Does java have
unsigned int primitives?

I ask because I'm writing methods to set and clear specific bits of an
int array. Or does Java already have these methods built in?

t.i.a

|\/|  /|  |2  |<
mehaase(at)sas(dot)upenn(dot)edu
Casey Hawthorne - 31 Mar 2004 08:40 GMT
JAVA has a consistent "int" size across platforms which is provided by
the JVM.

JAVA does not have unsigned int primitives - at least up to 1.4.
This is a pain for image processing applications which work on bytes.
You can use shorts -- but waste space.

JAVA has bitwise operators.

Regards,
Casey
Lāʻie Techie - 31 Mar 2004 09:13 GMT
> 1) Does int have a consistent size across platforms? 2) My IDE doesn't
> recognize the "unsigned" keyword. Does java have unsigned int primitives?
[quoted text clipped - 3 lines]
>
> t.i.a

Have a look at java.util.BitSet .  BitSet is basically a vector of bits.
It has methods for setting or getting individual bits.

AFAIK, char is the only unsigned primitive in Java.  The size of all
primitives are defined in the current specification.

HTH,
La'ie Techie
Roedy Green - 31 Mar 2004 10:23 GMT
>1) Does int have a consistent size across platforms?
>2) My IDE doesn't recognize the "unsigned" keyword. Does java have
>unsigned int primitives?

see http://mindprod.com/jgloss/primitive.html

1) yes, 32 bits.
2) char = unsigned 16-bit short, but alas so unsigned byte, int, long.

see http://mindprod.com/jgloss/unsigned.html
for how to fake it.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.