strange calculation results...?

J

Jeremy

hi,

when performing some calculations for display in a table, I
occasionally get the value '04294967295' which is equivalent to 2^32
-1. This value is incorrect as the numbers I'm dealing with are not of
this order.

I know the above details are pretty sketchy, but this looks like some
kind of overflow/underflow. Does anybody have any idea how this number
could crop up?

btw I'm using IBM jdk 1.4.0 on linux.
 
J

Jim White

Jeremy said:
when performing some calculations for display in a table, I
occasionally get the value '04294967295' which is equivalent to 2^32
-1. This value is incorrect as the numbers I'm dealing with are not of
this order.

I know the above details are pretty sketchy, but this looks like some
kind of overflow/underflow. Does anybody have any idea how this number
could crop up?

Most likely is that you've taken a Java "int" (32 bit two's complement
integer) -1 and converted it to an unsigned integer for display.
Perhaps some code like: ((long) i) & 0xFFFFFFFFL, or something suitable
in your display formatting code to show unsigned.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top