Web hosting contract - Chapter 20 Java Utilities Package and Bit Manipulation
Chapter 20 Java Utilities Package and Bit Manipulation 1185 Bit 1 Bit 2 Bit 1 ^Bit 2 0 0 0 1 0 1 0 1 1 1 1 0 Fig. 20.10Results of combining two bits with the bitwise exclusive OR operator (^). 20.10 The bitwise complement operator (~) sets all 1bits in its operand to 0in the result and sets all 0 bits to 1 in the result otherwise referred to as taking the one’s complement of the value. The fourth output window for Fig. 20.8 shows the results of taking the one s complement of the value 21845. The result is -21846. The program of Fig. 20.11 demonstrates the left shift operator (<<), the right shift operator with sign extension (>>) and the right shift operator with zero extension (>>>). Method getBits(lines 113 138) obtains a Stringcontaining the bit representation of the integer values. The program allows the user to enter an integer into a JTextField and press Enter to display the bit representation of the integer in a second JTextField. The the user can press a button representing a shift operation to perform a 1-bit shift and view the results of the shift in both integer and bitwise representation. 1 // Fig. 20.11: BitShift.java 2 // Using the bitwise shift operators. 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class BitShift extends JFrame { 12 private JTextField bitsField; 13 private JTextField valueField; 14 15 // set up GUI 16 public BitShift() 17 { 18 super( “Shifting bits” ); 19 20 Container container = getContentPane(); 21 container.setLayout( new FlowLayout() ); 22 23 container.add( new JLabel( “Integer to shift ” ) ); 24 25 // textfield for user to input integer 26 valueField = new JTextField( 12 ); Fig. 20.11 Fig. 20.11 Demonstrating the bitwise shift operators (part 1 of 5).
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.