aspose file tools
The moose likes Beginning Java and the fly likes About Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "About "Bit Pattern"" Watch "About "Bit Pattern"" New topic
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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About "Bit Pattern"
 
Similar Threads
Why does FileInputStream's read() method return integer?
shift operator
Bitwise complement operator
About primitive promotion.
what does these bitwise shift doing here ??