Tray
·
Jan 29, 2009
·
Viewed 324.3k times
·
Source
I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5.
I'm sure there is very easy way of doing this - I just don't know how.
Note that if you pass Integer.MIN_VALUE, the same value (still negative) will be returned, as the range of int does not allow the positive equivalent to be represented.
I am converting the incoming string into hash code by doing the following function but some of the values are negative. I don't think hash values should be negative. Please tell me what I am doing wrong.
int combine = (srcadd + …
Are hexadecimal numbers ever negative? If yes then how?
For binary you would have signed and unsigned.
How would one represent them in Hex? I need this for a hex routine I am about to embark upon.