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