Java binary literal usage -
all examples on binary literal like: int a=0b1011
question is, can translate existing variables form? example, fromint b=10000011;
want int c=0b10000011
.
you use integer.parseint(string, int)
, like,
int b = 10000011; int c = integer.parseint(string.valueof(b), 2); int d = 0b10000011; system.out.println(c == d);
and true
.
Comments
Post a Comment