This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Similar Threads
ascii to number conversion in java
Binary calculations
hexadecimal and octal numbers
doubt on char assignment
Is + , - r Unary operators?