Web space - Chapter 20 Java Utilities Package and Bit Manipulation

Chapter 20 Java Utilities Package and Bit Manipulation 1183 170 171 // for each bit append 0 or 1 to buffer 172 for ( int bit = 1; bit <= 32; bit++ ) { 173 174 // use displayMask to isolate bit and determine whether 175 // bit has valueof 0 or1 176 buffer.append( 177 ( value & displayMask ) == 0 ? '0' : '1' ); 178 179 // shift value one position to left 180 value <<= 1; 181 182 // append space to buffer every 8 bits 183 if( bit % 8 == 0 ) 184 buffer.append( ' ' ); 185 } 186 187 return buffer.toString(); 188 } 189 190 // execute application 191 public static void main( String args[] ) 192 { 193 MiscBitOps application = new MiscBitOps(); 194 195 application.setDefaultCloseOperation( 196 JFrame.EXIT_ON_CLOSE ); 197 } 198 199 } // end class MiscBitOps Fig. 20.8Demonstrating the bitwise AND, bitwise inclusive OR, bitwise exclusive OR Fig. 20.8 and bitwise complement operators (part 5 of 6).
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply