[5278] in java-interest
Questions with signed variables and boolean operations
daemon@ATHENA.MIT.EDU (Walter Szewelanczyk)
Mon Feb 5 03:47:53 1996
From: "Walter Szewelanczyk" <Walter@adco.com>
To: java-interest@java.sun.com
Date: Mon, 5 Feb 1996 02:12:11 +0000
Hi all,
I have yet another foolish question,
integer big = 0;
byte little = -112;
big |= little;
big still shows a value of -112 instead of 144. Why?? I asumed that
the |= was a binary "inclusive or" operator. I also assumed that the
<< left shift would shift over everything including the sign bit but
if I do the folowing
integer big = 0;
byte little = -1;
big |= little;
big <<=8;
The big ends up with -256. Which I suppose would make sense since it
appears to keep the sign of little when oring with big. It also
appears that I cannot create an "unsigned" int or byte so I am not
sure how to do what i need to do.
Thanks in advance,
Walt
********************************************************************************************
Walter Szewelanczyk Technical Director
Walter@adco.com NET VENTURE, Inc.
http://www.adco.com
"One must stay in a very RIGID state of FLEXABILITY"
********************************************************************************************
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com