java - How to decode the value encoded as one*100 + two*10 + three? -
how values one
, two
, three
back? following approach correct? looks no.
int encodedvalue = one*100 + two*10 + three; // following decryption part of procedure int 1 = encodedvalue / 100; int 2 = encodedvalue / 10; int 3 = encodedvalue % 10;
assuming two
, three
in range 0-9 (otherwise have ambiguity) want:
int 2 = (encodedvalue / 10) % 10;
... otherwise gets ten times one
value added it.
Comments
Post a Comment