Da hast du natürlich recht, byte = 2^8 d.h. von -127 bis +127 bzw. von 0 bis 255
In deinem Fall kommt Null raus, weil die ersten 8 Bit nicht verwendet werden (==immer 0 sind). Java wirft bei "Illegalen" Typecasts keine Exceptions sondern nimmt den Teil den es verarbeiten kann. In diesem Fall sind das die ersten 8Bit die wie schon erwähnt 0 sind.
Es sollte funktionieren wenn du den >> Operator verwendest:
Code:
String res;
byte bDatum = (byte) 9472 >> 8;
byte bMontag = 1;
byte bDienstag = 10;
etc.
if ((bDatum & bMontag) == bMontag) res += "Montag";
etc.
jak
____________________________________
Join the DNRC |
Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)