0

How can I convert a number to a base-24 string? And how can I convert this string back to a number?

e.g.: 25 in base-10 is 11 in base-24, 2B in base-24 is 48+11 = 59 in base-10

xanatos
  • 102,557
  • 10
  • 176
  • 249
Oh My Dog
  • 740
  • 7
  • 30
  • Other than the fact that you don't seem to be able to do hex conversion manually, `decimal` is a floating point type, so a decimal can be `5.2`... a floating point hex is something I haven't ever seen (not that it isn't possible, but...) – xanatos Jun 09 '15 at 08:30
  • @xanatos sorry, I use google translator for 'Decimal' and '24Hex' cause i don't know how to say "every 10 in 1" and "every 24 in 1" in English. – Oh My Dog Jun 09 '15 at 08:34
  • @ASh, that post only seems to cover going one way (base 10 -> base x) – David Arno Jun 09 '15 at 08:37
  • @OhMyDog Ok... I've changed your question to be clearer. – xanatos Jun 09 '15 at 08:38
  • 1
    @DavidArno, backward is simpler and also one answer has additional link where backward conversion is implemented: http://www.pvladov.com/2012/05/decimal-to-arbitrary-numeral-system.html, http://www.pvladov.com/2012/07/arbitrary-to-decimal-numeral-system.html – ASh Jun 09 '15 at 08:41
  • @xanatos thank you & i'm gonna to give google translator a -1... -_-! – Oh My Dog Jun 09 '15 at 08:49
  • *`From`* and *`To`* methods: http://stackoverflow.com/questions/923771/quickest-way-to-convert-a-base-10-number-to-any-base-in-net/35004409#35004409 – Diego May 14 '16 at 20:38

1 Answers1

1

This code is working fine both decimal to hex and hex to decimal

        var HexVal = "2B";
        int DecimalVal = Convert.ToInt32(HexVal, 16);
        Console.WriteLine(DecimalVal);
        string HexVal1 = DecimalVal.ToString("X");
        Console.WriteLine(HexVal1);
Ashokreddy
  • 344
  • 1
  • 11