【初心者】Java質問・相談スレッド123【歓迎】at TECH
【初心者】Java質問・相談スレッド123【歓迎】 - 暇つぶし2ch823:デフォルトの名無しさん
09/02/17 23:14:55
public class BitTest {
public static void main(String[] args) {
long i = 0;

for (i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE ; i ++) {
bittest((byte)i);
}

for (i = Integer.MIN_VALUE; i <= Integer.MAX_VALUE ; i ++) {
bittest((int)i);
}
}
public static void bittest(byte B_) {
byte c1 = (byte)((B_ & 0xFE) & 0xFF);
byte c2 = (byte)((B_ & 0xFE));

if (c1 != c2) {
System.out.println("error byte " + B_);
throw new RuntimeException();
}
}
public static void bittest(int B_) {
int c1 = (B_ & 0xFE) & 0xFF;
int c2 = (B_ & 0xFE);

if (c1 != c2) {
System.out.println("error int " + B_);
throw new RuntimeException();
}
}
}


次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch