| Author |
About "Bit Pattern"
|
Charles Cheng
Greenhorn
Joined: Nov 23, 2003
Posts: 1
|
|
Hello~ I am a freshman in javaranch thank teacher Yang brings me here. the following is my question.. how to print out the bit pattern of a value in any kind of data type? like byte,short,int,long,float,duoble etc. int a=7; print out "a": 00000000 00000000 00000000 00000111 you are so nice to answer this question...
|
 |
Vicken Karaoghlanian
Ranch Hand
Joined: Jul 21, 2003
Posts: 522
|
|
Originally posted by Charles Cheng: Hello~ I am a freshman in javaranch thank teacher Yang brings me here. the following is my question.. how to print out the bit pattern of a value in any kind of data type? like byte,short,int,long,float,duoble etc. int a=7; print out "a": 00000000 00000000 00000000 00000111 you are so nice to answer this question...
Hello Charles, and welcome to the ranch. Hope this helps.
|
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Welcome to JavaRanch, Charles! Vicken's suggestion will be useful when working with the smaller integral primitive data types. Take a look at a very similar method in the Long class for working with that larger integral type. Also, take a look at the Double class documentation for a method that will help out with those floating point types. [ December 31, 2003: Message edited by: Dirk Schreckmann ]
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: About "Bit Pattern"
|
|
|