I have a string type variable that represents 25-digit integer number in my c# code, for example 7590720001001011080190334.
I need to shrink the length of this number at least for 2-3 digit.
I thought that the easiest way is to convert this number into hexadecimal. I can't afford the bases with more capacity.
I checked out online services that decimal 7590720001001011080190334 (25 digit) is 64765C17B803752D9D97E (21 digit) in hex, that's good for me.
But in c# I faced a problem with the conversion between the bases.
The large numbers like mine I can store only in decimal type of variables but I get System.FormatException by doing this code:
decimal foo = 7590720001001011080190334m;
string bar = foo.ToString("X"); //throw System.FormatException
I saw in question Why does converting between decimal and hex throw a formatexception? that a hexadecimal string only supported by integral types in c#. That is too sad, cause some online services in javascript are possible to solve this problem.
Any thoughts how can I solve the conversation problem or the shrink problem?