![]() |
|
|
|||||||
![]() |
Java - Java unsigned integer type for memory addresses |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
Hi,
I'm writing a Java GUI that communicates with a debugger written in C++. I need to deal with visualizing memory locations and addresses and thus need to be able to handle 64bit unsigned address values in Java. Since Java doesn't have any native unsigned types - what's the best way to go about this? As an example of what my problem is consider the following case: The C++ debugging client sends me a list of all function entry points in a program. These are 64bit unsigned address values. My Java GUI receives them, sorts and displays them. Since Java interprets some of the numbers as negative the sorting is all screwed up... So - how do I best represent a 64bit unsigned integer value in Java? regards, Sören |
|
|
|
#2 |
|
Posts: n/a
|
Soeren Meyer-Eppler wrote:
> As an example of what my problem is consider the following case: The C++ > debugging client sends me a list of all function entry points in a > program. These are 64bit unsigned address values. My Java GUI receives > them, sorts and displays them. Since Java interprets some of the numbers > as negative the sorting is all screwed up... If sorting is your only problem, write a Comperator which treats the Java longs accordingly. If I am not mistaken: int compare(long a, long b) { if(a >= 0 && b < 0) { return -1; } else if(a < 0 && b >= 0) { return 1; } else { return (int)(a - b); } } You probably also have problems with printing. Just copy one of the many bin2dec functions which should be around on the net. I am to lazy to create one from out of head now. > So - how do I best represent a 64bit unsigned integer value in Java? As 64 bit singed longs. You only get into some trouble if you start to do some arithmetic with them. Then you can either use BigInteger (takes much more memory and CPU time), or write your own special arithmetic methods (which then partly re-implement what is already in BigInteger). /Thomas -- The comp.lang.java.gui FAQ: ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq http://www.uni-giessen.de/faq/archiv....java.gui.faq/ |
|
|
|
#3 |
|
Posts: n/a
|
On Mon, 17 Oct 2005 11:36:04 +0200, Soeren Meyer-Eppler
<Soeren.Meyer-> wrote or quoted : >Since Java interprets some of the numbers >as negative the sorting is all screwed up... All you need is an unsigned display method. Long.toHexString should suffice. -- Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts. |
|
|
|
#4 |
|
Posts: n/a
|
On Mon, 17 Oct 2005 12:08:55 +0200, Thomas Weidenfeller
<> wrote or quoted : >As 64 bit singed longs. You only get into some trouble if you start to >do some arithmetic with them. Then you can either use BigInteger (takes >much more memory and CPU time), or write your own special arithmetic >methods (which then partly re-implement what is already in BigInteger). Unsigned + and - are the same operations as signed. You are surely not going to multiply your addresses. You might shift them. You have >> and >>> to deal with signed and unsigned. < works the same for signed and unsigned. See http://mindprod.com/jgloss/unsigned.html -- Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts. |
|
|
|
#5 |
|
Posts: n/a
|
Soeren Meyer-Eppler wrote:
> So - how do I best represent a 64bit unsigned integer value in Java? Actually your problem is not how to represent 64-bit unsigned quantities, so much as how to represent /addresses/. One approach would be to set up a new class MemoryAddress which contains a 32- or 64-bit number, and which provides whatever behaviour (formatting, comparison, arithmetic, ...) your application requires. -- chris |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cisco 2600 - Inbound NAT translation/Port-forwarding not working | Greg | Hardware | 0 | 11-20-2008 06:33 PM |
| Eclipse - Axis2 - Java Webservices Error | amanjsingh | Software | 1 | 10-09-2007 08:03 AM |
| Need help on Modelsim VHDL syntax? ASAP:) | kaji | General Help Related Topics | 0 | 03-14-2007 09:43 PM |
| Need help on a Modelsim VHDL Syntax? ASAP:) | kaji | Software | 0 | 03-14-2007 09:43 PM |
| Need Help on a Modelsim VHDL Syntax....ASAP:) | kaji | Hardware | 0 | 03-14-2007 09:41 PM |