This project creates a class called ShowBits that allows
Display the bit pattern of any integer value in binary.
A class like this can be very useful in programming. For example, when debugging device driver code, it is often beneficial to be able to monitor the data stream in binary.
class ShowBits { int numbits; ShowBits(int n) { numbits = n; }
ShowBits creates objects that display a specified number of bits. For example, to create an object that displays the low-order 8 bits of a value, use
ShowBits byteval = new ShowBits(8)
The number of bits to be displayed is stored in numbits
To actually display the bit pattern, ShowBits provides the show( ),
methodNote that show( ) specifies a long parameter. However, this does not mean that you will always have to pass show( ) a long value. Due to Java's automatic type promotions, any integer type can be passed to show( ). The number of bits displayed is determined by the value stored in numbits. After each group of 8 bits, show( ) displays a space. This makes it easier to read the binary values of long bit patterns.
See example in repo
ShowBitsDemo
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3