File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Literal for binary number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Literal for binary number" Watch "Literal for binary number" New topic

Literal for binary number

Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
Hi !
There is a literal form to represent a binary number, as we do have with hexadecimal numbers (0xA34F) ? For example, how can i initialize a byte variable with a binary number ?
byte x = 0101011;
Thanks !

Gustavo Adolpho Bonesso<br />SCJP1.4
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
byte b = Byte.parseByte("0101011", 2);

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Literal for binary number