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 / General / May 2006

Tip: Looking for answers? Try searching our database.

byte datatype

Thread view: 
graniteraju@gmail.com - 18 May 2006 14:58 GMT
hi,
I have a quetsion in java for byte datatype does '0' correspond to
true and '1' to false or vice versa

thanks
Jeffrey Schwab - 18 May 2006 15:04 GMT
> hi,
>  I have a quetsion in java for byte datatype does '0' correspond to
> true and '1' to false or vice versa

Neither.  The boolean type is not directly convertible to char or any
other Java integer type.
Tobias Schröer - 18 May 2006 15:08 GMT
graniteraju@gmail.com schrieb:
> hi,
>  I have a quetsion in java for byte datatype does '0' correspond to
> true and '1' to false or vice versa
>
> thanks

I'd say neither, if I got you right.
byte is a number valuetype that ranges from -128 to 127 (or was it -127
to 128?).
For true and false you have the valuetype boolean.

However, you are free to encode true/false by using a byte, but I would
not suggest this.

Tobi
Matt Humphrey - 18 May 2006 15:15 GMT
> graniteraju@gmail.com schrieb:
>> hi,
[quoted text clipped - 6 lines]
> byte is a number valuetype that ranges from -128 to 127 (or was it -127 to
> 128?).

-128 to 127 in 2's complement.

> For true and false you have the valuetype boolean.
>
> However, you are free to encode true/false by using a byte, but I would
> not suggest this.
>
> Tobi
VisionSet - 18 May 2006 15:50 GMT
> hi,
>  I have a quetsion in java for byte datatype does '0' correspond to
> true and '1' to false or vice versa

Java encapsulates boolean & Boolean types such that the bit internal
representation is not available.  Consequently operations between scalar
types and booleans are not possible.

--
Mike W
Rhino - 18 May 2006 17:51 GMT
> hi,
> I have a quetsion in java for byte datatype does '0' correspond to
> true and '1' to false or vice versa

If you're looking for a datatype to represent true and false, you should
probably use boolean, not byte.
A boolean can only be true or false. Other responders have told you what the
byte datatype can hold.

--
Rhino


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.