File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regading Byte.MAX_VALUE

 
Chandra Sekhar
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the result of the following expression ?
(byte) (Byte.MAX_VALUE + 1) == Byte.MIN_VALUE
This will print true.
Can some one help me to find the reason why it prints true.
Regards
Chandrasekhar S
 
Jose Botella
Ranch Hand
Posts: 2120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Byte.MAX_VALUE is 127 , that is 0x7f
Byte.MIN_VALUE is -128 , that is 0x80
0x7f + 1 = 0x80

A simple knowledge about binary, hexadecimal and two's complement is necessary for the exam. Read about them in the web or maybe just search in the Ranch
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic