This week's book giveaway is in the Android forum.We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!See this thread for details.
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of Head First Android this week in the Android forum!

# Binary Notes

suresh kamsa
Ranch Hand

Joined: Jul 30, 2001
Posts: 149
All
I would like to know how to represent following in binary.
Byte.MAX_VALUE
Float.NEGATIVE_INFINITY
Float.POSITIVE_INFINITY
Short.MIN_VALUE
Short.MAX_VALUE
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
etc.
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
etc.
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)

Venkatesh Gowri
Greenhorn

Joined: Aug 15, 2002
Posts: 12
Hi
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.
http://docs.sun.com/source/806-3568/index.html
http://docs.sun.com/source/816-2464/index.html
hope these Help

Gowri Venkatesh

subject: Binary Notes