wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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]
Consider Paul's rocket mass heater.
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?