• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why "There is no literal representation for binary numbers in C, C++, or Java."?  RSS feed

 
ye shi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am reading Thinking in java, in Operator/Literals, it says "There is no literal representation for binary numbers in C, C++, or Java."
I am confused, seems "0b11001" could reprensent binary numbers?

int i = 0b100;
System.out.println(i);


the output should be 4.
 
ye shi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it, the author means display in binary format. need use toBinaryString( ) methods.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When was that edition written? The binary literal format was only introduced in Java 7, so if it's an older source then it would have missed it.
 
Paweł Baczyński
Bartender
Posts: 2077
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The latest edition of Thinking in Java uses Java SE5/6.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!