I would like to view binary reprsentations of integers in my watch window in eclipse when debugging (or hex). How do I do this?
views:
96answers:
2Your best option is probably to open the Expressinos view (Window -> Show View -> Expressions), right click, choose "Add Watch Expression" and then enter Integer.toBinaryString(yourInt)
, and click ok.
You can do this from Window->Preferences.
For primitives, browse to Java->Debug->Primitive Display Options
Here there is a checkbox for 'Display Hexadecimal values'. Check this, and you will see both decimal & hexadecimal representations for primitives in the 'value' column under Variables view when debugging.
For objects (Integer, Long, etc), browse to Java->Debug->Detail Formatters
For each type you care about, create a detail formatter that formats the value how you like. For java.lang.Integer, you could use the detail formatter: Integer.toHexString(this)
Make sure your detail formatter is enabled, and you should see the hexadecimal representation in the 'details' area when you select a variable from the Variables view.