java - does %d in String.format() work for unsigned integers also? -


in printf() remember unsigned there %u... can find no such %u in specs string.format()

so if have large unsigned int %d work correctly on it?

if want treat int if unsigned can to

int = ... string s = string.format("%d", & 0xffffffffl); 

this turns signed int long, 0 .. 2^31-1

to reverse can do

int = (int) long.parselong(s); string s2 = string.format("%d", & 0xffffffffl); 

and s2 same s provided in range.

btw: simplest thing might use long in first place. unless creating a lot of these memory trivial , code simpler.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -