It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Binary Notes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Binary Notes" Watch "Binary Notes" New topic

Binary Notes

suresh kamsa
Ranch Hand

Joined: Jul 30, 2001
Posts: 149
I would like to know how to represent following in binary.
and many more which I missed
I need to practice because I see many questions based on those. If any java guru direct me to any notes or any url site, I appreciate it.
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
With Integer.toBinaryString(int) you can see the bynary value for int arguments.
However it's very important that you know in two's complement the maximum positive value is formed by all but the most significant bits to one.
Byte.MAX_VALUE , 0111 1111
Short.MAX_VALUE , 0111 1111 1111 1111
And the fewer value (negative) has all to zero except the most significant.
Byte.MIN_VALUE , 1000 0000
Short.MIN_VALUE , 1000 0000 0000 0000
Please buy a book or search the web to learn about binary formats because is very important for the exam.
Hardly ever it's necessary to know the binary form of a floating point number because they are not going to tell you anything. They follow the IEEE 754 standars. Anyway, it's possible to see the binary representation via: Float.floatToRawIntBits(float) and Double.doubleToRawLongBits(double)

SCJP2. Please Indent your code using UBB Code
Venkatesh Gowri

Joined: Aug 15, 2002
Posts: 12
I browsed the Web and found some Information on the IEEE 754 format .SOme links went to the Sun site itself.So i guess these would be a good resouce.
hope these Help

Gowri Venkatesh
I agree. Here's the link:
subject: Binary Notes
It's not a secret anymore!