c++hexc++builderc++builder-xe

How to encode a Hex string to Integer in BCB XE


I want to convert a hex string to a 16 bit Decimal in RAD Studio C++ Builder XE.

For example, I have the hex string "8FC". The Binary representation of this is 100011111100. The Decimal representation of this is: 2300.

How to do this conversion in C++ Builder XE?


Solution

  • Finally, I find the correct way how to do this conversion on this article. It just try to call the StrToInt() procedure but prepend a "$" like this:

    s1 = "8FC";
    int i = StrToInt(UnicodeString("$") + s1);
    Edit1->Text = IntToStr(i);