プログラムdeタマゴ

nodamushiの著作物は、文章、画像、プログラムにかかわらず全てUnlicenseです

2011-01-16から1日間の記事一覧

ビット列を逆転する

あ〜、無駄だった。本当に無駄だったよ。 java.lang.Integerにreverse関数あったよ! でもせっかく考えたので記事にしておく。 public static int reverse(int n){ n = (n&0xffff0000)>>>16|(n&0xffff)<<16; n = (n&0xff00ff00)>>>8|(n&0xff00ff)<<8; n = (n…