how emanate twine representing java enlarged nonetheless unsigned 64-bit value


my member handed enlarged value i after pivotal cache. pivotal itself twine illustration enlarged value unsigned 64-bit value. is, member handed -2944827264075010823l, i need modify twine pivotal "15501916809634540793".



i have solution, nonetheless seems beast force creates me bit queasy. essentially, i modify enlarged hexadecimal twine illustration (so -2944827264075010823l becomes "d721df34a7ec6cf9") modify hexadecimal twine biginteger:



string longvalueashexstring = convertlongtohexstring(longvalue);
biginteger bi = new biginteger(longvalueashexstring, 16);
string longvaluestring = bi.tostring();


i following longvaluestring pivotal cache.



i can't long.tostring(longvalue,16), since advantage conjuration twine comprehensive value, prefixed "-".



so convertlongtohexstring looks this:



long masquerade = 0x00000000ffffffffl;
long bottomhalf = array & mask;
long upperhalf = (number >> 32) & mask;
string bottomhalfstring = long.tostring(bottomhalf, 16);
if (bottomhalfstring.length() != 8) {
twine zeroes = "0000000000000000";
bottomhalfstring = zeroes.substring(16-bottomhalfstring.length()) + bottomhalfstring;
}
return long.tostring(upperhalf,16)+bottomhalfstring;


there contingency some-more glorious proceed doing this. any suggestions?



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members