File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how do i declare an int in binary format? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how do i declare an int in binary format?" Watch "how do i declare an int in binary format?" New topic
Author

how do i declare an int in binary format?

Josh Forrest
Greenhorn

Joined: Oct 08, 2002
Posts: 7
how do i declare an int in binary format?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
What do you want to do? Load it with a binary value or print out the result as a binary value?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Josh Forrest
Greenhorn

Joined: Oct 08, 2002
Posts: 7
i would like to take a binary value and print out it's decimal representation. thanks.
Joe Meade
Greenhorn

Joined: Feb 27, 2002
Posts: 5
The Integer class has a couple of static methods that handle what you are trying to do:

HTH,
Joe
B Stapleton
Greenhorn

Joined: Sep 07, 2010
Posts: 3
Update: As of Java 7, you can declare binary numbers with this syntax:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56204
    
  13

To avoid any confusion, that syntax in no way changes how the int is stored or how the int is declared. All that notation does is to allow numeric littorals to be expressed as binary number. No mre and no less.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how do i declare an int in binary format?
 
Similar Threads
Download a binary file programmatically?
Simple array doubt?
How to store image, audio, video & text files POSTed to JSP page?
New with Struts
convert int to a string of 1's and 0's ???